Skip to content

Commit 265cd37

Browse files
committed
tests/unit: fix a regression due to a recent textX change
Related to: textX/textX@e808ff5
1 parent ff68e24 commit 265cd37

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

tasks.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,11 @@ def test_end2end(
317317

318318

319319
@task(aliases=["tu"])
320-
def test_unit(context):
320+
def test_unit(context, focus=None):
321321
Path(TEST_REPORTS_DIR).mkdir(parents=True, exist_ok=True)
322322

323+
focus_argument = f"-k {focus}" if focus is not None else ""
324+
323325
cwd = os.getcwd()
324326

325327
path_to_coverage_file = f"{cwd}/build/coverage/unit/.coverage"
@@ -331,22 +333,24 @@ def test_unit(context):
331333
--rcfile=.coveragerc.unit
332334
--data-file={path_to_coverage_file}
333335
-m pytest
336+
{focus_argument}
334337
--junit-xml={TEST_REPORTS_DIR}/tests_unit.pytest.junit.xml
335338
-o cache_dir=build/pytest_unit_with_coverage
336339
-o junit_suite_name="StrictDoc Unit Tests"
337340
tests/unit/
338341
""",
339342
)
340-
run_invoke_with_tox(
341-
context,
342-
ToxEnvironment.CHECK,
343-
f"""
344-
coverage report
345-
--sort=cover
346-
--rcfile=.coveragerc.unit
347-
--data-file={path_to_coverage_file}
348-
""",
349-
)
343+
if not focus:
344+
run_invoke_with_tox(
345+
context,
346+
ToxEnvironment.CHECK,
347+
f"""
348+
coverage report
349+
--sort=cover
350+
--rcfile=.coveragerc.unit
351+
--data-file={path_to_coverage_file}
352+
""",
353+
)
350354

351355

352356
@task(test_unit)

tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ def test_edge_case_02_uid_present_but_empty_with_no_space_character():
10291029
_ = reader.read(input_sdoc)
10301030

10311031
assert exc_info.type is TextXSyntaxError
1032-
assert "Expected ': '" == exc_info.value.args[0].decode("utf-8")
1032+
assert "Expected ': '" == exc_info.value.args[0]
10331033

10341034

10351035
def test_edge_case_03_uid_present_but_empty_with_space_character():
@@ -1050,7 +1050,7 @@ def test_edge_case_03_uid_present_but_empty_with_space_character():
10501050
assert exc_info.type is TextXSyntaxError
10511051
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[
10521052
0
1053-
].decode("utf-8")
1053+
]
10541054

10551055

10561056
def test_edge_case_04_uid_present_but_empty_with_two_space_characters():
@@ -1071,7 +1071,7 @@ def test_edge_case_04_uid_present_but_empty_with_two_space_characters():
10711071
assert exc_info.type is TextXSyntaxError
10721072
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[
10731073
0
1074-
].decode("utf-8")
1074+
]
10751075

10761076

10771077
def test_edge_case_10_empty_multiline_field():
@@ -1094,7 +1094,7 @@ def test_edge_case_10_empty_multiline_field():
10941094
"Expected '^\\[ANCHOR: ' or '[LINK: ' or "
10951095
"'(?ms)(?!^<<<)(?!\\[LINK: "
10961096
"([\\w]+[\\w()\\-\\/.: ]*))(?!^\\[ANCHOR: "
1097-
"([\\w]+[\\w()\\-\\/.: ]*)).'" in exc_info.value.args[0].decode("utf-8")
1097+
"([\\w]+[\\w()\\-\\/.: ]*)).'" in exc_info.value.args[0]
10981098
)
10991099

11001100

@@ -1115,9 +1115,7 @@ def test_edge_case_11_empty_multiline_field_with_one_newline():
11151115
_ = reader.read(input_sdoc)
11161116

11171117
assert exc_info.type is TextXSyntaxError
1118-
assert "Node statement cannot be empty." == exc_info.value.args[0].decode(
1119-
"utf-8"
1120-
)
1118+
assert "Node statement cannot be empty." == exc_info.value.args[0]
11211119

11221120

11231121
def test_edge_case_19_empty_section_title():
@@ -1139,7 +1137,7 @@ def test_edge_case_19_empty_section_title():
11391137
assert exc_info.type is TextXSyntaxError
11401138
assert (
11411139
"Expected 'MID: ' or 'UID: ' or 'LEVEL: ' or 'TITLE: '"
1142-
== exc_info.value.args[0].decode("utf-8")
1140+
== exc_info.value.args[0]
11431141
)
11441142

11451143

@@ -1160,7 +1158,7 @@ def test_edge_case_20_empty_section_title():
11601158
_ = reader.read(input_sdoc)
11611159

11621160
assert exc_info.type is TextXSyntaxError
1163-
assert "Expected SingleLineString" == exc_info.value.args[0].decode("utf-8")
1161+
assert "Expected SingleLineString" == exc_info.value.args[0]
11641162

11651163

11661164
def test_edge_case_21_section_title_with_empty_space():
@@ -1181,7 +1179,7 @@ def test_edge_case_21_section_title_with_empty_space():
11811179
_ = reader.read(input_sdoc)
11821180

11831181
assert exc_info.type is TextXSyntaxError
1184-
assert "Expected SingleLineString" in exc_info.value.args[0].decode("utf-8")
1182+
assert "Expected SingleLineString" in exc_info.value.args[0]
11851183

11861184

11871185
def test_edge_case_22_section_title_with_two_empty_spaces():
@@ -1202,7 +1200,7 @@ def test_edge_case_22_section_title_with_two_empty_spaces():
12021200
_ = reader.read(input_sdoc)
12031201

12041202
assert exc_info.type is TextXSyntaxError
1205-
assert "Expected SingleLineString" in exc_info.value.args[0].decode("utf-8")
1203+
assert "Expected SingleLineString" == exc_info.value.args[0]
12061204

12071205

12081206
def test_edge_case_23_leading_spaces_do_not_imply_empy_field(

0 commit comments

Comments
 (0)