Closed
Description
- a detailed description of the bug or problem you are having
- output of
pip list
from the virtual environment you are using - pytest and operating system versions
- minimal example if possible
Description, reproducer and traceback
When the pytest's test suite is run with explicit -Wdefault
, a few tests fail:
$ tox -e py313 -- -Wdefault
.pkg: _optional_hooks> python /usr/lib/python3.14/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.14/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_editable> python /usr/lib/python3.14/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: build_sdist> python /usr/lib/python3.14/site-packages/pyproject_api/_backend.py True setuptools.build_meta
py313: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/pytest/.tox/.tmp/package/2/pytest-8.5.0.dev1+g80dfa2db8.tar.gz
py313: commands[0]> pytest -Wdefault
========================================================= test session starts =========================================================
platform linux -- Python 3.13.3, pytest-8.5.0.dev1+g80dfa2db8, pluggy-1.6.0
cachedir: .tox/py313/.pytest_cache
rootdir: /tmp/pytest
configfile: pyproject.toml
testpaths: testing
plugins: hypothesis-6.133.2
collected 3913 items
testing/_py/test_local.py .................................................................ss..............s.................x. [ 2%]
....Xs.....................................sssssss............................x... [ 4%]
testing/acceptance_test.py ..... [ 4%]
testing/code/test_code.py ................. [ 5%]
testing/code/test_excinfo.py .................s.......s........................................................................ [ 7%]
............................................................ [ 9%]
testing/code/test_source.py ....................................................... [ 10%]
testing/deprecated_test.py .......... [ 10%]
testing/freeze/tests/test_doctest.txt . [ 10%]
testing/freeze/tests/test_trivial.py .. [ 11%]
testing/io/test_pprint.py ...................................... [ 11%]
testing/io/test_saferepr.py ............. [ 12%]
testing/io/test_terminalwriter.py ................................................. [ 13%]
testing/io/test_wcwidth.py ................. [ 14%]
testing/logging/test_fixture.py ................... [ 14%]
testing/logging/test_formatter.py .... [ 14%]
testing/logging/test_reporting.py .. [ 14%]
testing/python/approx.py .sss..sssss............................s............sssssss................ss.......... [ 16%]
testing/python/collect.py .. [ 16%]
testing/python/fixtures.py ....s...... [ 17%]
testing/python/integration.py .... [ 17%]
testing/python/metafunc.py ........................................... [ 18%]
testing/python/raises.py ........................... [ 19%]
testing/python/raises_group.py .............s............. [ 19%]
testing/test_argcomplete.py .. [ 19%]
testing/test_assertion.py ......................................................................... [ 21%]
testing/test_assertrewrite.py ................................................ [ 22%]
testing/test_capture.py .............................................................s.. [ 24%]
testing/test_collection.py .. [ 24%]
testing/test_compat.py .......... [ 24%]
testing/test_config.py ............................................................. [ 26%]
testing/test_conftest.py ........... [ 26%]
testing/test_debugging.py . [ 26%]
testing/test_doctest.py ............. [ 27%]
testing/test_entry_points.py . [ 27%]
testing/test_faulthandler.py ... [ 27%]
testing/test_findpaths.py ..............s... [ 27%]
testing/test_helpconfig.py . [ 27%]
testing/test_junitxml.py ......... [ 27%]
testing/test_legacypath.py .... [ 27%]
testing/test_main.py ..... [ 28%]
testing/test_mark.py .............. [ 28%]
testing/test_mark_expression.py ............................................................................................... [ 30%]
............................................. [ 32%]
testing/test_monkeypatch.py ............................... [ 32%]
testing/test_nodes.py .... [ 32%]
testing/test_parseopt.py ............................. [ 33%]
testing/test_pastebin.py ..... [ 33%]
testing/test_pluginmanager.py ......... [ 34%]
testing/test_pytester.py ..................... [ 34%]
testing/test_recwarn.py ......................................................... [ 36%]
testing/test_runner.py ............... [ 36%]
testing/test_scope.py .... [ 36%]
testing/test_skipping.py . [ 36%]
testing/test_stash.py . [ 36%]
testing/test_terminal.py ................................................. [ 37%]
testing/test_tmpdir.py ...s............... [ 38%]
testing/test_warning_types.py ............. [ 38%]
testing/test_warnings.py . [ 38%]
testing/acceptance_test.py ..................................................s...x.........................s... [ 40%]
testing/code/test_excinfo.py .............sssssssss....... [ 41%]
testing/deprecated_test.py .... [ 41%]
testing/examples/test_issue519.py . [ 41%]
testing/logging/test_fixture.py ........ [ 41%]
testing/logging/test_reporting.py .................................................. [ 43%]
testing/python/approx.py . [ 43%]
testing/python/collect.py ............................................................................... [ 45%]
testing/python/fixtures.py ...........................................................................x........................ [ 47%]
.................................................................................s......... [ 50%]
testing/python/integration.py ................ [ 50%]
testing/python/metafunc.py ..................................................................... [ 52%]
testing/python/raises.py .... [ 52%]
testing/python/raises_group.py .. [ 52%]
testing/python/show_fixtures_per_test.py ........ [ 52%]
testing/test_assertion.py ........................................................................... [ 54%]
testing/test_assertrewrite.py ................................................................... [ 56%]
testing/test_cacheprovider.py ......................................................... [ 57%]
testing/test_capture.py ......x..................................... [ 58%]
testing/test_collect_imported_tests.py ... [ 58%]
testing/test_collection.py ................x............................................s................s... [ 61%]
testing/test_config.py ..................x..................................................................................... [ 63%]
.............................................. [ 64%]
testing/test_conftest.py .............s............................. [ 65%]
testing/test_debugging.py ............. [ 66%]
testing/test_doctest.py ................................................................x...................................... [ 68%]
......................... [ 69%]
testing/test_error_diffs.py ............ [ 69%]
testing/test_faulthandler.py ... [ 69%]
testing/test_helpconfig.py ........ [ 70%]
testing/test_junitxml.py ..................................................................................................s... [ 72%]
s........................ [ 73%]
testing/test_legacypath.py .......... [ 73%]
testing/test_link_resolve.py . [ 73%]
testing/test_main.py .............. [ 74%]
testing/test_mark.py ......................................................................x................... [ 76%]
testing/test_monkeypatch.py ...s [ 76%]
testing/test_nodes.py .... [ 76%]
testing/test_parseopt.py . [ 76%]
testing/test_pastebin.py ... [ 76%]
testing/test_pathlib.py ............................................................s.......................................... [ 79%]
........ [ 79%]
testing/test_pluginmanager.py ....s............ [ 79%]
testing/test_pytester.py x........................ [ 80%]
testing/test_python_path.py ...... [ 80%]
testing/test_recwarn.py ..... [ 80%]
testing/test_reports.py .................. [ 81%]
testing/test_runner.py ........................x........................... [ 82%]
testing/test_runner_xunit.py ............. [ 82%]
testing/test_session.py .......................... [ 83%]
testing/test_setuponly.py .......................... [ 84%]
testing/test_setupplan.py ... [ 84%]
testing/test_skipping.py ......................................................................................... [ 86%]
testing/test_stepwise.py .................. [ 87%]
testing/test_terminal.py ...................................................s.................................................. [ 89%]
...........ssss......s............................... [ 91%]
testing/test_threadexception.py ......F. [ 91%]
testing/test_tmpdir.py .................... [ 91%]
testing/test_unittest.py ......................sssssss.................................s............ [ 93%]
testing/test_unraisableexception.py ......F... [ 93%]
testing/test_warning_types.py . [ 93%]
testing/test_warnings.py .....F.............sss.......... [ 94%]
testing/acceptance_test.py ..... [ 94%]
testing/python/collect.py . [ 94%]
testing/python/fixtures.py .. [ 94%]
testing/test_assertion.py ............ [ 95%]
testing/test_assertrewrite.py .......... [ 95%]
testing/test_capture.py ........................s [ 96%]
testing/test_collection.py ... [ 96%]
testing/test_config.py .. [ 96%]
testing/test_debugging.py sssssssssss.ssssssssssssssss.sssss....ssss.sss [ 97%]
testing/test_faulthandler.py ..s. [ 97%]
testing/test_helpconfig.py .. [ 97%]
testing/test_legacypath.py . [ 97%]
testing/test_meta.py .................................................................... [ 99%]
testing/test_pytester.py ....s [ 99%]
testing/test_recwarn.py . [ 99%]
testing/test_reports.py . [ 99%]
testing/test_terminal.py ss.. [ 99%]
testing/test_unittest.py s. [ 99%]
testing/test_unraisableexception.py . [ 99%]
testing/test_warnings.py .......... [100%]
============================================================== FAILURES ===============================================================
___________________________________________ test_unhandled_thread_exception_after_teardown ____________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-mgorny/pytest-19/test_unhandled_thread_exception_after_teardown0')>
def test_unhandled_thread_exception_after_teardown(pytester: Pytester) -> None:
pytester.makepyfile(
test_it="""
import threading
import pytest
def thread():
def oops():
raise ValueError("Oops")
t = threading.Thread(target=oops, name="MyThread")
t.start()
t.join()
def test_it(request):
request.config.add_cleanup(thread)
"""
)
result = pytester.runpytest()
# TODO: should be a test failure or error
> assert result.ret == pytest.ExitCode.INTERNAL_ERROR
E AssertionError: assert <ExitCode.OK: 0> == <ExitCode.INTERNAL_ERROR: 3>
E + where <ExitCode.OK: 0> = <RunResult ret=0 len(stdout.lines)=8 len(stderr.lines)=0 duration=0.46s>.ret
E + and <ExitCode.INTERNAL_ERROR: 3> = <enum 'ExitCode'>.INTERNAL_ERROR
E + where <enum 'ExitCode'> = pytest.ExitCode
/tmp/pytest/testing/test_threadexception.py:217: AssertionError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.13.3, pytest-8.5.0.dev1+g80dfa2db8, pluggy-1.6.0
rootdir: /tmp/pytest-of-mgorny/pytest-19/test_unhandled_thread_exception_after_teardown0
collected 1 item
test_it.py . [100%]
============================== 1 passed in 0.00s ===============================
______________________________________________________ test_refcycle_unraisable _______________________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-mgorny/pytest-19/test_refcycle_unraisable0')>
def test_refcycle_unraisable(pytester: Pytester) -> None:
# see: https://github.com/pytest-dev/pytest/issues/10404
pytester.makepyfile(
test_it="""
import pytest
class BrokenDel:
def __init__(self):
self.self = self # make a reference cycle
def __del__(self):
raise ValueError("del is broken")
def test_it():
BrokenDel()
"""
)
with _disable_gc():
result = pytester.runpytest()
# TODO: should be a test failure or error
> assert result.ret == pytest.ExitCode.INTERNAL_ERROR
E AssertionError: assert <ExitCode.OK: 0> == <ExitCode.INTERNAL_ERROR: 3>
E + where <ExitCode.OK: 0> = <RunResult ret=0 len(stdout.lines)=8 len(stderr.lines)=0 duration=0.46s>.ret
E + and <ExitCode.INTERNAL_ERROR: 3> = <enum 'ExitCode'>.INTERNAL_ERROR
E + where <enum 'ExitCode'> = pytest.ExitCode
/tmp/pytest/testing/test_unraisableexception.py:263: AssertionError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.13.3, pytest-8.5.0.dev1+g80dfa2db8, pluggy-1.6.0
rootdir: /tmp/pytest-of-mgorny/pytest-19/test_refcycle_unraisable0
collected 1 item
test_it.py . [100%]
============================== 1 passed in 0.00s ===============================
___________________________________________________ test_works_with_filterwarnings ____________________________________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-mgorny/pytest-19/test_works_with_filterwarnings0')>
def test_works_with_filterwarnings(pytester: Pytester) -> None:
"""Ensure our warnings capture does not mess with pre-installed filters (#2430)."""
pytester.makepyfile(
"""
import warnings
class MyWarning(Warning):
pass
warnings.filterwarnings("error", category=MyWarning)
class TestWarnings(object):
def test_my_warning(self):
try:
warnings.warn(MyWarning("warn!"))
assert False
except MyWarning:
assert True
"""
)
result = pytester.runpytest()
> result.stdout.fnmatch_lines(["*== 1 passed in *"])
E Failed: nomatch: '*== 1 passed in *'
E and: '============================= test session starts =============================='
E and: 'platform linux -- Python 3.13.3, pytest-8.5.0.dev1+g80dfa2db8, pluggy-1.6.0'
E and: 'rootdir: /tmp/pytest-of-mgorny/pytest-19/test_works_with_filterwarnings0'
E and: 'collected 1 item'
E and: ''
E and: 'test_works_with_filterwarnings.py F [100%]'
E and: ''
E and: '=================================== FAILURES ==================================='
E and: '_________________________ TestWarnings.test_my_warning _________________________'
E and: ''
E and: 'self = <test_works_with_filterwarnings.TestWarnings object at 0x7f982a93a710>'
E and: ''
E and: ' def test_my_warning(self):'
E and: ' try:'
E and: ' warnings.warn(MyWarning("warn!"))'
E and: '> assert False'
E and: 'E assert False'
E and: ''
E and: 'test_works_with_filterwarnings.py:12: AssertionError'
E and: '=============================== warnings summary ==============================='
E and: 'test_works_with_filterwarnings.py::TestWarnings::test_my_warning'
E and: ' /tmp/pytest-of-mgorny/pytest-19/test_works_with_filterwarnings0/test_works_with_filterwarnings.py:11: MyWarning: warn!'
E and: ' warnings.warn(MyWarning("warn!"))'
E and: ''
E and: '-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html'
E and: '=========================== short test summary info ============================'
E and: 'FAILED test_works_with_filterwarnings.py::TestWarnings::test_my_warning - ass...'
E and: '========================= 1 failed, 1 warning in 0.00s ========================='
E remains unmatched: '*== 1 passed in *'
/tmp/pytest/testing/test_warnings.py:173: Failed
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.13.3, pytest-8.5.0.dev1+g80dfa2db8, pluggy-1.6.0
rootdir: /tmp/pytest-of-mgorny/pytest-19/test_works_with_filterwarnings0
collected 1 item
test_works_with_filterwarnings.py F [100%]
=================================== FAILURES ===================================
_________________________ TestWarnings.test_my_warning _________________________
self = <test_works_with_filterwarnings.TestWarnings object at 0x7f982a93a710>
def test_my_warning(self):
try:
warnings.warn(MyWarning("warn!"))
> assert False
E assert False
test_works_with_filterwarnings.py:12: AssertionError
=============================== warnings summary ===============================
test_works_with_filterwarnings.py::TestWarnings::test_my_warning
/tmp/pytest-of-mgorny/pytest-19/test_works_with_filterwarnings0/test_works_with_filterwarnings.py:11: MyWarning: warn!
warnings.warn(MyWarning("warn!"))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test_works_with_filterwarnings.py::TestWarnings::test_my_warning - ass...
========================= 1 failed, 1 warning in 0.00s =========================
========================================================== warnings summary ===========================================================
testing/test_collection.py::TestNodeKeywords::test_duplicates_handled_correctly
/tmp/pytest-of-mgorny/pytest-19/test_duplicates_handled_correctly0/test_duplicates_handled_correctly.py:2: PytestUnknownMarkWarning: Unknown pytest.mark.kw - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
pytestmark = pytest.mark.kw
testing/test_collection.py::TestNodeKeywords::test_duplicates_handled_correctly
/tmp/pytest-of-mgorny/pytest-19/test_duplicates_handled_correctly0/test_duplicates_handled_correctly.py:4: PytestUnknownMarkWarning: Unknown pytest.mark.kw - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
pytestmark = pytest.mark.kw
testing/test_pathlib.py::TestImportPath::test_no_meta_path_found[True]
<frozen importlib._bootstrap>:1249: ImportWarning: sys.meta_path is empty
testing/test_threadexception.py::test_unhandled_thread_exception_after_teardown
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/threadexception.py:58: PytestUnhandledThreadExceptionWarning: Exception in thread MyThread
Traceback (most recent call last):
File "/usr/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
self.run()
~~~~~~~~^^
File "/usr/lib/python3.13/threading.py", line 992, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pytest-of-mgorny/pytest-19/test_unhandled_thread_exception_after_teardown0/test_it.py", line 6, in oops
raise ValueError("Oops")
ValueError: Oops
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
testing/test_unraisableexception.py::test_refcycle_unraisable
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/unraisableexception.py:65: PytestUnraisableExceptionWarning: Exception ignored in: <function BrokenDel.__del__ at 0x7f982da9ce00>
Traceback (most recent call last):
File "/tmp/pytest-of-mgorny/pytest-19/test_refcycle_unraisable0/test_it.py", line 8, in __del__
raise ValueError("del is broken")
ValueError: del is broken
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================== XPASSES ===============================================================
======================================================= short test summary info =======================================================
FAILED testing/test_threadexception.py::test_unhandled_thread_exception_after_teardown - AssertionError: assert <ExitCode.OK: 0> == <ExitCode.INTERNAL_ERROR: 3>
FAILED testing/test_unraisableexception.py::test_refcycle_unraisable - AssertionError: assert <ExitCode.OK: 0> == <ExitCode.INTERNAL_ERROR: 3>
FAILED testing/test_warnings.py::test_works_with_filterwarnings - Failed: nomatch: '*== 1 passed in *'
XPASS testing/_py/test_local.py::TestLocalPath::test_make_numbered_dir_multiprocess_safe - #11603
===================== 3 failed, 3780 passed, 118 skipped, 11 xfailed, 1 xpassed, 5 warnings in 1266.05s (0:21:06) =====================
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-ab8a2c0b-0bbc-4d3c-a495-b55743aa671e/popen-gw4
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-ab8a2c0b-0bbc-4d3c-a495-b55743aa671e/popen-gw4'
warnings.warn(
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-ab8a2c0b-0bbc-4d3c-a495-b55743aa671e
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-ab8a2c0b-0bbc-4d3c-a495-b55743aa671e'
warnings.warn(
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-3f9c18e9-d729-4c3b-b5fc-592558e89708/popen-gw3
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-3f9c18e9-d729-4c3b-b5fc-592558e89708/popen-gw3'
warnings.warn(
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-3f9c18e9-d729-4c3b-b5fc-592558e89708
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-3f9c18e9-d729-4c3b-b5fc-592558e89708'
warnings.warn(
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-dd098764-abed-44a3-bf67-26226790a709/popen-gw4
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-dd098764-abed-44a3-bf67-26226790a709/popen-gw4'
warnings.warn(
/tmp/pytest/.tox/py313/lib/python3.13/site-packages/_pytest/pathlib.py:96: PytestWarning: (rm_rf) error removing /tmp/pytest-of-mgorny/garbage-dd098764-abed-44a3-bf67-26226790a709
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-mgorny/garbage-dd098764-abed-44a3-bf67-26226790a709'
warnings.warn(
py313: exit 1 (1267.07 seconds) /tmp/pytest> pytest -Wdefault pid=588370
py313: FAIL code 1 (1275.37=setup[8.30]+cmd[1267.07] seconds)
evaluation failed :( (1275.65 seconds)
pip list
$ .tox/py313/bin/pip list
Package Version
------------------ ---------------------
argcomplete 3.6.2
attrs 25.3.0
certifi 2025.4.26
charset-normalizer 3.4.2
elementpath 5.0.1
hypothesis 6.133.2
idna 3.10
iniconfig 2.1.0
mock 5.2.0
packaging 25.0
pip 25.1.1
pluggy 1.6.0
Pygments 2.19.1
pytest 8.5.0.dev1+g80dfa2db8
requests 2.32.3
setuptools 80.9.0
sortedcontainers 2.4.0
urllib3 2.4.0
xmlschema 4.0.1
Reproduced with 80dfa2d and 8.4.0.
Metadata
Metadata
Assignees
Labels
No labels