Skip to content

Commit 802c5e4

Browse files
committed
Test that --regex-variant controls regex format
1 parent c4814c6 commit 802c5e4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/acceptance/test_format_regex_opts.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# test on a JavaScript regex which is not a valid python regex
2-
# `--format-regex=default` should accept it
3-
# `--format-regex=python` should reject it
2+
# `--regex-variant=default` should accept it
3+
# `--regex-variant=python` should reject it
44
#
55
# check these options against documents with invalid and valid python regexes to confirm
66
# that they are behaving as expected
@@ -43,6 +43,10 @@
4343
("--disable-formats", "regex"),
4444
("--format-regex", "default"),
4545
("--format-regex", "python"),
46+
("--regex-variant", "python"),
47+
("--regex-variant", "default"),
48+
("--regex-variant", "default", "--format-regex", "python"),
49+
("--regex-variant", "python", "--format-regex", "default"),
4650
]
4751
)
4852
def regexopts(request):
@@ -108,7 +112,10 @@ def test_regex_format_js_specific(run_line, tmp_path, regexopts):
108112
doc = tmp_path / "doc.json"
109113
doc.write_text(json.dumps(JS_REGEX_DOCUMENT))
110114

111-
expect_ok = regexopts != ("--format-regex", "python")
115+
expect_ok = regexopts[:2] not in (
116+
("--format-regex", "python"),
117+
("--regex-variant", "python"),
118+
)
112119

113120
res = run_line(
114121
[

0 commit comments

Comments
 (0)