pytest
pytest copied to clipboard
Failures with terminal coloring in selftesting
- [x] a detailed description of the bug or problem you are having
- [x] output of
pip list
from the virtual environment you are using - [x] pytest and operating system versions
- [x] minimal example if possible
When running pytest
there are multiple failures:
========================================================================== FAILURES ==========================================================================
____________________________________________________ test_code_highlight[with markup and code_highlight] _____________________________________________________
has_markup = True, code_highlight = True, expected = '{kw}assert{hl-reset} {number}0{hl-reset}\n'
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>
@pytest.mark.parametrize(
("has_markup", "code_highlight", "expected"),
[
pytest.param(
True,
True,
"{kw}assert{hl-reset} {number}0{hl-reset}\n",
id="with markup and code_highlight",
),
pytest.param(
True,
False,
"assert 0\n",
id="with markup but no code_highlight",
),
pytest.param(
False,
True,
"assert 0\n",
id="without markup but with code_highlight",
),
pytest.param(
False,
False,
"assert 0\n",
id="neither markup nor code_highlight",
),
],
)
def test_code_highlight(has_markup, code_highlight, expected, color_mapping):
f = io.StringIO()
tw = terminalwriter.TerminalWriter(f)
tw.hasmarkup = has_markup
tw.code_highlight = code_highlight
tw._write_source(["assert 0"])
> assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected])
E AssertionError: assert ['assert 0\n'] == ['\x1b[94mass...[39;49;00m\n']
E At index 0 diff: 'assert 0\n' != '\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n'
E Use -v to get more diff
/home/gideon/PycharmProjects/pytest/testing/io/test_terminalwriter.py:287: AssertionError
_______________________________________________________________________ test_color_yes _______________________________________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_color_yes0')>, color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>
def test_color_yes(pytester: Pytester, color_mapping) -> None:
p1 = pytester.makepyfile(
"""
def fail():
assert 0
def test_this():
fail()
"""
)
result = pytester.runpytest("--color=yes", str(p1))
> result.stdout.fnmatch_lines(
color_mapping.format_for_fnmatch(
[
"{bold}=*= test session starts =*={reset}",
"collected 1 item",
"",
"test_color_yes.py {red}F{reset}{red} * [100%]{reset}",
"",
"=*= FAILURES =*=",
"{red}{bold}_*_ test_this _*_{reset}",
"",
" {kw}def{hl-reset} {function}test_this{hl-reset}():",
"> fail()",
"",
"{bold}{red}test_color_yes.py{reset}:5: ",
"_ _ * _ _*",
"",
" {kw}def{hl-reset} {function}fail{hl-reset}():",
"> {kw}assert{hl-reset} {number}0{hl-reset}",
"{bold}{red}E assert 0{reset}",
"",
"{bold}{red}test_color_yes.py{reset}:2: AssertionError",
"{red}=*= {red}{bold}1 failed{reset}{red} in *s{reset}{red} =*={reset}",
]
)
)
E Failed: fnmatch: '\x1b[[]1m=*= test session starts =*=\x1b[[]0m'
E with: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E nomatch: 'collected 1 item'
E and: 'platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0'
E and: 'rootdir: /tmp/pytest-of-gideon/pytest-1/test_color_yes0'
E exact match: 'collected 1 item'
E exact match: ''
E fnmatch: 'test_color_yes.py \x1b[[]31mF\x1b[[]0m\x1b[[]31m * [[]100%]\x1b[[]0m'
E with: 'test_color_yes.py \x1b[31mF\x1b[0m\x1b[31m [100%]\x1b[0m'
E exact match: ''
E fnmatch: '=*= FAILURES =*='
E with: '=================================== FAILURES ==================================='
E fnmatch: '\x1b[[]31m\x1b[[]1m_*_ test_this _*_\x1b[[]0m'
E with: '\x1b[31m\x1b[1m__________________________________ test_this ___________________________________\x1b[0m'
E exact match: ''
E nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_this\x1b[[]39;49;00m():'
E and: ' def test_this():'
E and: '> fail()'
E and: ''
E and: '\x1b[1m\x1b[31mtest_color_yes.py\x1b[0m:5: '
E and: '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ '
E and: ''
E and: ' def fail():'
E and: '> assert 0'
E and: '\x1b[1m\x1b[31mE assert 0\x1b[0m'
E and: ''
E and: '\x1b[1m\x1b[31mtest_color_yes.py\x1b[0m:2: AssertionError'
E and: '\x1b[36m\x1b[1m=========================== short test summary info ============================\x1b[0m'
E and: '\x1b[31mFAILED\x1b[0m test_color_yes.py::\x1b[1mtest_this\x1b[0m - assert 0'
E and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E remains unmatched: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_this\x1b[[]39;49;00m():'
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:1257: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_color_yes0
collected 1 item
test_color_yes.py F [100%]
=================================== FAILURES ===================================
__________________________________ test_this ___________________________________
def test_this():
> fail()
test_color_yes.py:5:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def fail():
> assert 0
E assert 0
test_color_yes.py:2: AssertionError
=========================== short test summary info ============================
FAILED test_color_yes.py::test_this - assert 0
============================== 1 failed in 0.01s ===============================
________________________________________________________ TestCodeHighlight.test_code_highlight_simple ________________________________________________________
self = <test_terminal.TestCodeHighlight object at 0x7fe849beba60>
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_code_highlight_simple0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>
def test_code_highlight_simple(self, pytester: Pytester, color_mapping) -> None:
pytester.makepyfile(
"""
def test_foo():
assert 1 == 10
"""
)
result = pytester.runpytest("--color=yes")
> result.stdout.fnmatch_lines(
color_mapping.format_for_fnmatch(
[
" {kw}def{hl-reset} {function}test_foo{hl-reset}():",
"> {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}",
"{bold}{red}E assert 1 == 10{reset}",
]
)
)
E Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
E and: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E and: 'platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0'
E and: 'rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_simple0'
E and: 'collected 1 item'
E and: ''
E and: 'test_code_highlight_simple.py \x1b[31mF\x1b[0m\x1b[31m [100%]\x1b[0m'
E and: ''
E and: '=================================== FAILURES ==================================='
E and: '\x1b[31m\x1b[1m___________________________________ test_foo ___________________________________\x1b[0m'
E and: ''
E and: ' def test_foo():'
E and: '> assert 1 == 10'
E and: '\x1b[1m\x1b[31mE assert 1 == 10\x1b[0m'
E and: ''
E and: '\x1b[1m\x1b[31mtest_code_highlight_simple.py\x1b[0m:2: AssertionError'
E and: '\x1b[36m\x1b[1m=========================== short test summary info ============================\x1b[0m'
E and: '\x1b[31mFAILED\x1b[0m test_code_highlight_simple.py::\x1b[1mtest_foo\x1b[0m - assert 1 == 10'
E and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E remains unmatched: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:2472: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_simple0
collected 1 item
test_code_highlight_simple.py F [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
> assert 1 == 10
E assert 1 == 10
test_code_highlight_simple.py:2: AssertionError
=========================== short test summary info ============================
FAILED test_code_highlight_simple.py::test_foo - assert 1 == 10
============================== 1 failed in 0.01s ===============================
_____________________________________________________ TestCodeHighlight.test_code_highlight_continuation _____________________________________________________
self = <test_terminal.TestCodeHighlight object at 0x7fe849bebbb0>
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_code_highlight_continuation0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>
def test_code_highlight_continuation(
self, pytester: Pytester, color_mapping
) -> None:
pytester.makepyfile(
"""
def test_foo():
print('''
'''); assert 0
"""
)
result = pytester.runpytest("--color=yes")
> result.stdout.fnmatch_lines(
color_mapping.format_for_fnmatch(
[
" {kw}def{hl-reset} {function}test_foo{hl-reset}():",
" {print}print{hl-reset}({str}'''{hl-reset}{str}{hl-reset}",
"> {str} {hl-reset}{str}'''{hl-reset}); {kw}assert{hl-reset} {number}0{hl-reset}",
"{bold}{red}E assert 0{reset}",
]
)
)
E Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
E and: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E and: 'platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0'
E and: 'rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_continuation0'
E and: 'collected 1 item'
E and: ''
E and: 'test_code_highlight_continuation.py \x1b[31mF\x1b[0m\x1b[31m [100%]\x1b[0m'
E and: ''
E and: '=================================== FAILURES ==================================='
E and: '\x1b[31m\x1b[1m___________________________________ test_foo ___________________________________\x1b[0m'
E and: ''
E and: ' def test_foo():'
E and: " print('''"
E and: "> '''); assert 0"
E and: '\x1b[1m\x1b[31mE assert 0\x1b[0m'
E and: ''
E and: '\x1b[1m\x1b[31mtest_code_highlight_continuation.py\x1b[0m:3: AssertionError'
E and: '----------------------------- Captured stdout call -----------------------------'
E and: ''
E and: ' '
E and: '\x1b[36m\x1b[1m=========================== short test summary info ============================\x1b[0m'
E and: '\x1b[31mFAILED\x1b[0m test_code_highlight_continuation.py::\x1b[1mtest_foo\x1b[0m - assert 0'
E and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E remains unmatched: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:2494: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_continuation0
collected 1 item
test_code_highlight_continuation.py F [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
print('''
> '''); assert 0
E assert 0
test_code_highlight_continuation.py:3: AssertionError
----------------------------- Captured stdout call -----------------------------
=========================== short test summary info ============================
FAILED test_code_highlight_continuation.py::test_foo - assert 0
============================== 1 failed in 0.01s ===============================
_____________________________________________________ TestCodeHighlight.test_code_highlight_custom_theme _____________________________________________________
self = <test_terminal.TestCodeHighlight object at 0x7fe849bebd00>
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_code_highlight_custom_theme0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fe84127d220>
def test_code_highlight_custom_theme(
self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
) -> None:
pytester.makepyfile(
"""
def test_foo():
assert 1 == 10
"""
)
monkeypatch.setenv("PYTEST_THEME", "solarized-dark")
monkeypatch.setenv("PYTEST_THEME_MODE", "dark")
result = pytester.runpytest("--color=yes")
> result.stdout.fnmatch_lines(
color_mapping.format_for_fnmatch(
[
" {kw}def{hl-reset} {function}test_foo{hl-reset}():",
"> {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}",
"{bold}{red}E assert 1 == 10{reset}",
]
)
)
E Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
E and: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E and: 'platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0'
E and: 'rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_custom_theme0'
E and: 'collected 1 item'
E and: ''
E and: 'test_code_highlight_custom_theme.py \x1b[31mF\x1b[0m\x1b[31m [100%]\x1b[0m'
E and: ''
E and: '=================================== FAILURES ==================================='
E and: '\x1b[31m\x1b[1m___________________________________ test_foo ___________________________________\x1b[0m'
E and: ''
E and: ' def test_foo():'
E and: '> assert 1 == 10'
E and: '\x1b[1m\x1b[31mE assert 1 == 10\x1b[0m'
E and: ''
E and: '\x1b[1m\x1b[31mtest_code_highlight_custom_theme.py\x1b[0m:2: AssertionError'
E and: '\x1b[36m\x1b[1m=========================== short test summary info ============================\x1b[0m'
E and: '\x1b[31mFAILED\x1b[0m test_code_highlight_custom_theme.py::\x1b[1mtest_foo\x1b[0m - assert 1 == 10'
E and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E remains unmatched: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:2517: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_custom_theme0
collected 1 item
test_code_highlight_custom_theme.py F [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
> assert 1 == 10
E assert 1 == 10
test_code_highlight_custom_theme.py:2: AssertionError
=========================== short test summary info ============================
FAILED test_code_highlight_custom_theme.py::test_foo - assert 1 == 10
============================== 1 failed in 0.01s ===============================
____________________________________________________ TestCodeHighlight.test_code_highlight_invalid_theme _____________________________________________________
self = <test_terminal.TestCodeHighlight object at 0x7fe849bebe50>
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fe840054e50>
def test_code_highlight_invalid_theme(
self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
) -> None:
pytester.makepyfile(
"""
def test_foo():
assert 1 == 10
"""
)
monkeypatch.setenv("PYTEST_THEME", "invalid")
result = pytester.runpytest_subprocess("--color=yes")
> result.stderr.fnmatch_lines(
"ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. "
"Only valid pygment styles are allowed."
)
E Failed: remains unmatched: "ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. Only valid pygment styles are allowed."
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:2538: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
running: /home/gideon/PycharmProjects/pytest/venv/bin/python3.9 -mpytest --basetemp=/tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme0/runpytest-0 --color=yes
in: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme0
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme0
collected 1 item
test_code_highlight_invalid_theme.py F [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
> assert 1 == 10
E assert 1 == 10
test_code_highlight_invalid_theme.py:2: AssertionError
=========================== short test summary info ============================
FAILED test_code_highlight_invalid_theme.py::test_foo - assert 1 == 10
============================== 1 failed in 0.02s ===============================
__________________________________________________ TestCodeHighlight.test_code_highlight_invalid_theme_mode __________________________________________________
self = <test_terminal.TestCodeHighlight object at 0x7fe849bebfa0>
pytester = <Pytester PosixPath('/tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme_mode0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fe8400548b0>
def test_code_highlight_invalid_theme_mode(
self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
) -> None:
pytester.makepyfile(
"""
def test_foo():
assert 1 == 10
"""
)
monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
result = pytester.runpytest_subprocess("--color=yes")
> result.stderr.fnmatch_lines(
"ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. "
"The only allowed values are 'dark' and 'light'."
)
E Failed: remains unmatched: "ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. The only allowed values are 'dark' and 'light'."
/home/gideon/PycharmProjects/pytest/testing/test_terminal.py:2554: Failed
-------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------
running: /home/gideon/PycharmProjects/pytest/venv/bin/python3.9 -mpytest --basetemp=/tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme_mode0/runpytest-0 --color=yes
in: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme_mode0
============================= test session starts ==============================
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /tmp/pytest-of-gideon/pytest-1/test_code_highlight_invalid_theme_mode0
collected 1 item
test_code_highlight_invalid_theme_mode.py F [100%]
=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________
def test_foo():
> assert 1 == 10
E assert 1 == 10
test_code_highlight_invalid_theme_mode.py:2: AssertionError
=========================== short test summary info ============================
FAILED test_code_highlight_invalid_theme_mode.py::test_foo - assert 1 == 10
============================== 1 failed in 0.02s ===============================
================================================================== short test summary info ===================================================================
FAILED testing/io/test_terminalwriter.py::test_code_highlight[with markup and code_highlight] - AssertionError: assert ['assert 0\n'] == ['\x1b[94mass...[39;49;00m\n']
FAILED testing/test_terminal.py::test_color_yes - Failed: fnmatch: '\x1b[[]1m=*= test session starts =*=\x1b[[]0m'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_simple - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_continuation - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_custom_theme - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_invalid_theme - Failed: remains unmatched: "ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. Only valid pygment styles are allowed."
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_invalid_theme_mode - Failed: remains unmatched: "ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. The only allowed values are 'dark' and 'light'."
============================================ 7 failed, 3234 passed, 135 skipped, 11 xfailed in 159.15s (0:02:39) =============================================
They seem to be related to terminal coloring
pytest
info:
platform linux -- Python 3.9.15, pytest-7.2.0.dev421+gcca029d55, pluggy-1.0.0
rootdir: /path/to/pytest, configfile: pyproject.toml, testpaths: testing
plugins: hypothesis-6.57.1
pip list
output:
Package Version
---------------- -----------------------
attrs 22.1.0
elementpath 3.0.2
exceptiongroup 1.0.4
hypothesis 6.57.1
iniconfig 1.1.1
packaging 21.3
pip 22.3.1
pluggy 1.0.0
pyparsing 3.0.9
pytest 7.2.0.dev421+gcca029d55
setuptools 65.5.1
sortedcontainers 2.4.0
tomli 2.0.1
wheel 0.38.4
xmlschema 2.1.1
pytest --version
:
pytest 7.2.0.dev421+gcca029d55
OS: Linux Mint 20.3 Cinnamon
Rerunning the failed test fails again
Can you show your env
, especially TERM
, NO_COLOR
and PY_COLORS
?
Can you show your
env
, especiallyTERM
,NO_COLOR
andPY_COLORS
?
COLORTERM=truecolor
TERM=xterm-256color
NO_COLOR
and PY_COLORS
are not set
Thanks. Not sure off-hand what the culprit would be then! Maybe someone else has an idea.
If needed, I can provide more details about my system/terminal or try again with different settings
I ran it on my other machine (same OS (different version: 19.3), same environment variables) and it failed with the exact same tests.
Also seeing this with 7.4.4 on macOS (using python3.8 here but happens in python3.10 as well)
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.8.13, pytest-7.4.4, pluggy-1.3.0 -- /sw/bin/python3.8
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/sw/build.build/pytest-py38-7.4.4-1/pytest-7.4.4/.hypothesis/examples')
rootdir: /sw/build.build/pytest-py38-7.4.4-1/pytest-7.4.4
configfile: pyproject.toml
testpaths: testing
plugins: xprocess-0.23.0, hypothesis-6.42.1, cov-4.1.0, timeout-2.2.0, pyfakefs-5.3.4, xdist-3.5.0
collected 3471 items / 1 deselected / 3470 selected
testing/acceptance_test.py::TestGeneralUsage::test_docstring_on_hookspec PASSED [ 0%]
testing/acceptance_test.py::TestInvocationVariants::test_invoke_with_invalid_type PASSED [ 0%]
...
<bunch of passing tests>
...
______________________________________________________________ test_code_highlight[with markup and code_highlight] _______________________________________________________________
has_markup = True, code_highlight = True, expected = '{kw}assert{hl-reset} {number}0{hl-reset}{endline}\n', color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>
@pytest.mark.parametrize(
("has_markup", "code_highlight", "expected"),
[
pytest.param(
True,
True,
"{kw}assert{hl-reset} {number}0{hl-reset}{endline}\n",
id="with markup and code_highlight",
),
pytest.param(
True,
False,
"assert 0\n",
id="with markup but no code_highlight",
),
pytest.param(
False,
True,
"assert 0\n",
id="without markup but with code_highlight",
),
pytest.param(
False,
False,
"assert 0\n",
id="neither markup nor code_highlight",
),
],
)
def test_code_highlight(has_markup, code_highlight, expected, color_mapping):
f = io.StringIO()
tw = terminalwriter.TerminalWriter(f)
tw.hasmarkup = has_markup
tw.code_highlight = code_highlight
tw._write_source(["assert 0"])
> assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected])
E AssertionError: assert ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n'] == ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\x1b[90m\x1b[39;49;00m\n']
E At index 0 diff: '\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n' != '\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\x1b[90m\x1b[39;49;00m\n'
E Full diff:
E - ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\x1b[90m\x1b[39;49;00m\n']
E ? ----------------------
E + ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n']
/sw/build.build/pytest-py38-7.4.4-1/pytest-7.4.4/testing/io/test_terminalwriter.py:287: AssertionError
...
<some other similar failures in various testing/test_terminal.py>
...
============================================================================ short test summary info =============================================================================
FAILED testing/io/test_terminalwriter.py::test_code_highlight[with markup and code_highlight] - AssertionError: assert ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n'] == ['\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\x1b[90m\x1b[39;49;00m\n']
FAILED testing/test_junitxml.py::test_random_report_log_xdist - FileNotFoundError: [Errno 2] No such file or directory: '/private/tmp/pytest-of-fink-bld/pytest-61/test_random_report_log_xdist0/junit.xml'
FAILED testing/test_junitxml.py::test_runs_twice_xdist - FileNotFoundError: [Errno 2] No such file or directory: '/private/tmp/pytest-of-fink-bld/pytest-61/test_runs_twice_xdist0/junit.xml'
FAILED testing/test_terminal.py::TestTerminalFunctional::test_header_trailer_info - Failed: nomatch: 'plugins: *'
FAILED testing/test_terminal.py::TestTerminalFunctional::test_verbose_reporting_xdist - Failed: remains unmatched: '*FAIL*test_verbose_reporting_xdist.py::test_fail*'
FAILED testing/test_terminal.py::test_color_yes - Failed: fnmatch: '\x1b[[]1m=*= test session starts =*=\x1b[[]0m'
FAILED testing/test_terminal.py::TestProgressOutputStyle::test_xdist_normal - Failed: remains unmatched: '\\.{20} \\s+ \\[100%\\]'
FAILED testing/test_terminal.py::TestProgressOutputStyle::test_xdist_normal_count - Failed: remains unmatched: '\\.{20} \\s+ \\[20/20\\]'
FAILED testing/test_terminal.py::TestProgressOutputStyle::test_xdist_verbose - Failed: line '\\[gw\\d\\] \\[\\s*\\d+%\\] PASSED test_bar.py::test_bar\\[1\\]' not found in output
FAILED testing/test_terminal.py::TestProgressWithTeardown::test_xdist_normal - Failed: remains unmatched: '[\\.E]{40} \\s+ \\[100%\\]'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_simple - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():\x1b[[]90m\x1b[[]39;49;00m'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_continuation - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():\x1b[[]90m\x1b[[]39;49;00m'
FAILED testing/test_terminal.py::TestCodeHighlight::test_code_highlight_custom_theme - Failed: nomatch: ' \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():\x1b[[]90m\x1b[[]39;49;00m'
FAILED testing/test_debugging.py::TestPDB::test_pdb_interaction_capturing_simple
FAILED testing/test_debugging.py::TestPDB::test_pdb_interaction_capturing_twice
FAILED testing/test_debugging.py::TestPDB::test_pdb_with_injected_do_debug
FAILED testing/test_debugging.py::TestDebuggingBreakpoints::test_pdb_not_altered
FAILED testing/test_debugging.py::test_pdb_suspends_fixture_capturing[capfd]
FAILED testing/test_debugging.py::test_pdb_suspends_fixture_capturing[capsys]
XPASS testing/_py/test_local.py::TestLocalPath::test_make_numbered_dir_multiprocess_safe #11603
========================================== 19 failed, 3392 passed, 46 skipped, 1 deselected, 12 xfailed, 1 xpassed in 253.32s (0:04:13) ==========================================
This is using Apple's built-in terminal that sets these variables mentioned above: TERM=xterm-256color No other *COLOR* envvar sets.