Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Fixed
``<test-module-name>`` component despite the ``README.rst`` claimed.
Existed projects could set ``pm-pattern-file-fmt`` to
``{class}/{fn}{callspec}`` to preserve backward compatibility.
- Keep original line endings when reading expectation files.

Removed
-------
Expand Down
3 changes: 2 additions & 1 deletion src/matcher/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def _read_expected_file_content(self) -> None:
pytest.skip(f'Pattern file not found `{self._pattern_filename}`')

if self._expected_file_content is None:
self._expected_file_content = self._pattern_filename.read_text()
with self._pattern_filename.open(newline='') as f:
self._expected_file_content = f.read()

def __eq__(self, text: object) -> bool:
if not isinstance(text, str):
Expand Down
18 changes: 18 additions & 0 deletions test/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,21 @@ def test_sfx(capfd, expected_out):
# Run all tests with pytest
result = pytester.runpytest()
result.assert_outcomes(passed=1)


def crlf_test(ourtestdir, expectdir) -> None:
# Write a sample expectations file
expectdir.makepatternfile('.out', test_sample_out='Hello Africa!\r\n')
# Write a sample test
ourtestdir.makepyfile(r"""
def test_sample_out(capfd, expected_out):
print('Hello Africa!\r\n', end='')
stdout, stderr = capfd.readouterr()
assert expected_out == stdout
assert stderr == ''
"""
)

# Run all tests with pytest
result = ourtestdir.runpytest()
result.assert_outcomes(passed=1)