Skip to content

Commit b5232c8

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

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
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 & 15 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():
@@ -1048,9 +1048,7 @@ def test_edge_case_03_uid_present_but_empty_with_space_character():
10481048
_ = reader.read(input_sdoc)
10491049

10501050
assert exc_info.type is TextXSyntaxError
1051-
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[
1052-
0
1053-
].decode("utf-8")
1051+
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[0]
10541052

10551053

10561054
def test_edge_case_04_uid_present_but_empty_with_two_space_characters():
@@ -1069,9 +1067,7 @@ def test_edge_case_04_uid_present_but_empty_with_two_space_characters():
10691067
_ = reader.read(input_sdoc)
10701068

10711069
assert exc_info.type is TextXSyntaxError
1072-
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[
1073-
0
1074-
].decode("utf-8")
1070+
assert "Expected '([\\w]+[\\w()\\-\\/.: ]*)'" in exc_info.value.args[0]
10751071

10761072

10771073
def test_edge_case_10_empty_multiline_field():
@@ -1094,7 +1090,7 @@ def test_edge_case_10_empty_multiline_field():
10941090
"Expected '^\\[ANCHOR: ' or '[LINK: ' or "
10951091
"'(?ms)(?!^<<<)(?!\\[LINK: "
10961092
"([\\w]+[\\w()\\-\\/.: ]*))(?!^\\[ANCHOR: "
1097-
"([\\w]+[\\w()\\-\\/.: ]*)).'" in exc_info.value.args[0].decode("utf-8")
1093+
"([\\w]+[\\w()\\-\\/.: ]*)).'" in exc_info.value.args[0]
10981094
)
10991095

11001096

@@ -1115,9 +1111,7 @@ def test_edge_case_11_empty_multiline_field_with_one_newline():
11151111
_ = reader.read(input_sdoc)
11161112

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

11221116

11231117
def test_edge_case_19_empty_section_title():
@@ -1139,7 +1133,7 @@ def test_edge_case_19_empty_section_title():
11391133
assert exc_info.type is TextXSyntaxError
11401134
assert (
11411135
"Expected 'MID: ' or 'UID: ' or 'LEVEL: ' or 'TITLE: '"
1142-
== exc_info.value.args[0].decode("utf-8")
1136+
== exc_info.value.args[0]
11431137
)
11441138

11451139

@@ -1160,7 +1154,7 @@ def test_edge_case_20_empty_section_title():
11601154
_ = reader.read(input_sdoc)
11611155

11621156
assert exc_info.type is TextXSyntaxError
1163-
assert "Expected SingleLineString" == exc_info.value.args[0].decode("utf-8")
1157+
assert "Expected SingleLineString" == exc_info.value.args[0]
11641158

11651159

11661160
def test_edge_case_21_section_title_with_empty_space():
@@ -1181,7 +1175,7 @@ def test_edge_case_21_section_title_with_empty_space():
11811175
_ = reader.read(input_sdoc)
11821176

11831177
assert exc_info.type is TextXSyntaxError
1184-
assert "Expected SingleLineString" in exc_info.value.args[0].decode("utf-8")
1178+
assert "Expected SingleLineString" in exc_info.value.args[0]
11851179

11861180

11871181
def test_edge_case_22_section_title_with_two_empty_spaces():
@@ -1202,7 +1196,7 @@ def test_edge_case_22_section_title_with_two_empty_spaces():
12021196
_ = reader.read(input_sdoc)
12031197

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

12071201

12081202
def test_edge_case_23_leading_spaces_do_not_imply_empy_field(

0 commit comments

Comments
 (0)