Skip to content

Commit

Permalink
Fix parse errors for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed May 23, 2022
1 parent bd5367a commit ecc3cca
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions python/test/test_junit.py
Expand Up @@ -11,6 +11,7 @@

test_files_path = pathlib.Path(__file__).parent / 'files'


class TestElement(Element):
__test__ = False

Expand Down Expand Up @@ -394,12 +395,17 @@ def test_parse_junit_xml_files_with_empty_file(self):
))

def test_parse_junit_xml_files_with_non_xml_file(self):
result_file = str(test_files_path / 'non-xml.xml')
result_file = test_files_path / 'non-xml.xml'
result_filename = str(result_file)
expected_filename = ('file:/' + result_file.absolute().as_posix()) if result_file.drive else result_file.name
self.assertEqual(
parse_junit_xml_files([result_file]),
parse_junit_xml_files([result_filename]),
ParsedUnitTestResults(
files=1,
errors=[ParseError(file=result_file, message="Start tag expected, '<' not found, line 1, column 1 (non-xml.xml, line 1)", line=None, column=None)],
errors=[ParseError(file=result_filename,
message=f"Start tag expected, '<' not found, line 1, column 1 ({expected_filename}, line 1)",
line=None,
column=None)],
suites=0,
suite_tests=0,
suite_skipped=0,
Expand All @@ -410,12 +416,17 @@ def test_parse_junit_xml_files_with_non_xml_file(self):
))

def test_parse_junit_xml_files_with_corrupt_xml_file(self):
result_file = str(test_files_path / 'corrupt-xml.xml')
result_file = test_files_path / 'corrupt-xml.xml'
result_filename = str(result_file)
expected_filename = ('file:/' + result_file.absolute().as_posix()) if result_file.drive else result_file.name
self.assertEqual(
parse_junit_xml_files([result_file]),
parse_junit_xml_files([result_filename]),
ParsedUnitTestResults(
files=1,
errors=[ParseError(file=result_file, message='Premature end of data in tag skipped line 9, line 11, column 22 (corrupt-xml.xml, line 11)', line=None, column=None)],
errors=[ParseError(file=result_filename,
message=f'Premature end of data in tag skipped line 9, line 11, column 22 ({expected_filename}, line 11)',
line=None,
column=None)],
suites=0,
suite_tests=0,
suite_skipped=0,
Expand Down

0 comments on commit ecc3cca

Please sign in to comment.