Bug 2458644 - pytest fails to build with Python 3.15: DeprecationWarning: This process (pid=1119) is multi-threaded, use of forkpty() may lead to deadlocks in the child.
Summary: pytest fails to build with Python 3.15: DeprecationWarning: This process (pid...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: pytest
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Thomas Moschny
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.15
TreeView+ depends on / blocked
 
Reported: 2026-04-15 10:24 UTC by Karolina Surma
Modified: 2026-04-22 09:17 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2026-04-15 10:24:47 UTC
pytest fails to build with Python 3.15.0a8.

40 tests fail with the elevated DeprecationWarning:

_____________ TestTerminal.test_report_collect_after_half_a_second _____________
[gw2] linux -- Python 3.15.0 /usr/bin/python3

self = <test_terminal.TestTerminal object at 0x7f032c34ce50>
pytester = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw2/test_report_collect_after_half_a_second0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f032c87dbe0>

    def test_report_collect_after_half_a_second(
        self, pytester: Pytester, monkeypatch: MonkeyPatch
    ) -> None:
        """Test for "collecting" being updated after 0.5s"""
        pytester.makepyfile(
            **{
                "test1.py": """
                import _pytest.terminal
    
                _pytest.terminal.REPORT_COLLECTING_RESOLUTION = 0
    
                def test_1():
                    pass
                    """,
                "test2.py": "def test_2(): pass",
            }
        )
        # Explicitly test colored output.
        monkeypatch.setenv("PY_COLORS", "1")
    
>       child = pytester.spawn_pytest("-v test1.py test2.py")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/builddir/build/BUILD/pytest-8.4.2-build/pytest-8.4.2/testing/test_terminal.py:203: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/pytest-8.4.2-build/BUILDROOT/usr/lib/python3.15/site-packages/_pytest/pytester.py:1515: in spawn_pytest
    return self.spawn(cmd, expect_timeout=expect_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/builddir/build/BUILD/pytest-8.4.2-build/BUILDROOT/usr/lib/python3.15/site-packages/_pytest/pytester.py:1529: in spawn
    child = pexpect.spawn(cmd, logfile=logfile, timeout=expect_timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:205: in __init__
    self._spawn(command, args, preexec_fn, dimensions)
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:303: in _spawn
    self.ptyproc = self._spawnpty(self.args, env=self.env,
/usr/lib/python3.15/site-packages/pexpect/pty_spawn.py:315: in _spawnpty
    return ptyprocess.PtyProcess.spawn(args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.15/site-packages/ptyprocess/ptyprocess.py:230: in spawn
    pid, fd = pty.fork()
              ^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def fork():
        """fork() -> (pid, master_fd)
        Fork and make the child a session leader with a controlling terminal."""
    
        try:
>           pid, fd = os.forkpty()
                      ^^^^^^^^^^^^
E           DeprecationWarning: This process (pid=1119) is multi-threaded, use of forkpty() may lead to deadlocks in the child.

/usr/lib64/python3.15/pty.py:66: DeprecationWarning

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/10318598-pytest/

For all our attempts to build pytest with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/pytest/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Karolina Surma 2026-04-22 09:17:51 UTC
After filtering out the Deprecation Warnings there's one issue left:


_________________ TestRewriteOnImport.test_dont_write_bytecode _________________
[gw3] linux -- Python 3.15.0 /usr/bin/python3

self = <test_assertrewrite.TestRewriteOnImport object at 0x7f07b559dd00>
pytester = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_dont_write_bytecode0')>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f07acd56430>

    def test_dont_write_bytecode(self, pytester: Pytester, monkeypatch) -> None:
        monkeypatch.delenv("PYTHONPYCACHEPREFIX", raising=False)
    
        pytester.makepyfile(
            """
            import os
            def test_no_bytecode():
                assert "__pycache__" in __cached__
                assert not os.path.exists(__cached__)
                assert not os.path.exists(os.path.dirname(__cached__))"""
        )
        monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", "1")
>       assert pytester.runpytest_subprocess().ret == 0
E       AssertionError: assert <ExitCode.TESTS_FAILED: 1> == 0
E        +  where <ExitCode.TESTS_FAILED: 1> = <RunResult ret=1 len(stdout.lines)=19 len(stderr.lines)=0 duration=0.27s>.ret
E        +    where <RunResult ret=1 len(stdout.lines)=19 len(stderr.lines)=0 duration=0.27s> = runpytest_subprocess()
E        +      where runpytest_subprocess = <Pytester PosixPath('/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_dont_write_bytecode0')>.runpytest_subprocess

/builddir/build/BUILD/pytest-9.0.3-build/pytest-9.0.3/testing/test_assertrewrite.py:1090: AssertionError
----------------------------- Captured stdout call -----------------------------
running: /usr/bin/python3 -mpytest --basetemp=/tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_dont_write_bytecode0/runpytest-0
     in: /tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_dont_write_bytecode0
============================= test session starts ==============================
platform linux -- Python 3.15.0a8, pytest-9.0.3, pluggy-1.6.0
rootdir: /tmp/pytest-of-mockbuild/pytest-0/popen-gw3/test_dont_write_bytecode0
collected 1 item

test_dont_write_bytecode.py F                                            [100%]

=================================== FAILURES ===================================
_______________________________ test_no_bytecode _______________________________

    def test_no_bytecode():
>       assert "__pycache__" in __cached__
                                ^^^^^^^^^^
E       NameError: name '__cached__' is not defined

test_dont_write_bytecode.py:3: NameError
=========================== short test summary info ============================
FAILED test_dont_write_bytecode.py::test_no_bytecode - NameError: name '__cac...


Note You need to log in before you can comment on or make changes to this bug.