Skip to content

Commit

Permalink
test: removed unimportant lines from stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Feb 1, 2025
1 parent 4636f75 commit fe8296d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
16 changes: 15 additions & 1 deletion src/inline_snapshot/testing/_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,21 @@ def run_pytest(
assert result.returncode == returncode

if stderr is not None:
assert result.stderr.decode() == stderr

original = result.stderr.decode().splitlines()
lines = [
line
for line in original
if not any(
s in line
for s in [
'No entry for terminal type "unknown"',
"using dumb terminal settings.",
]
)
]

assert "\n".join(lines) == stderr

if report is not None:

Expand Down
16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,22 @@ def errors(self):
result = re.sub(r"\d+\.\d+s", "<time>", result)
return result

@property
def stderr(self):
original = self._result.stderr.lines
lines = [
line
for line in original
if not any(
s in line
for s in [
'No entry for terminal type "unknown"',
"using dumb terminal settings.",
]
)
]
return pytest.LineMatcher(lines)

def errorLines(self):
result = self._join_lines(
[line for line in self.stdout.lines if line and line[:2] in ("> ", "E ")]
Expand Down
7 changes: 1 addition & 6 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,12 +718,7 @@ def test_a():
["--inline-snapshot=creaigflen"],
report=snapshot(""),
returncode=snapshot(4),
stderr=snapshot(
"""\
ERROR: --inline-snapshot=creaigflen is a unknown flag
"""
),
stderr=snapshot("ERROR: --inline-snapshot=creaigflen is a unknown flag\n"),
)


Expand Down
18 changes: 3 additions & 15 deletions tests/test_xdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,19 @@ def test_a():
"""
)

def filter_error_lines(result):
lines = result.stderr.lines
return [
line
for line in lines
if line
not in (
'No entry for terminal type "unknown";',
"using dumb terminal settings.",
)
]

result = project.run("-n=auto", "--inline-snapshot=disable")

assert result.report == snapshot("")

assert filter_error_lines(result) == snapshot([])
assert result.stderr.lines == snapshot([])

assert result.ret == 1

result = project.run("-n=auto", "--inline-snapshot=fix")

assert result.report == snapshot("")

assert filter_error_lines(result) == snapshot(
assert result.stderr.lines == snapshot(
["ERROR: --inline-snapshot=fix can not be combined with xdist", ""]
)

Expand All @@ -92,6 +80,6 @@ def filter_error_lines(result):
"INFO: inline-snapshot was disabled because you used xdist"
)

assert filter_error_lines(result) == snapshot([])
assert result.stderr.lines == snapshot([])

assert result.ret == 0

0 comments on commit fe8296d

Please sign in to comment.