Skip to content

test_functional_work_flow and test_interruption_does_not_cleanup from 1.0.2 fail with py38 and py310 #162

@nieder

Description

@nieder

Describe the bug
Running tests on the pytest-xprocess-1.0.2 code fails the above two tests.

To Reproduce

PYTHONPATH=/opt/sw/build.build/pytest-xprocess-py38-1.0.2-1/pytest-xprocess-1.0.2 /opt/sw/bin/python3.8 -B -m pytest -vv
===================================================================== test session starts ======================================================================
platform darwin -- Python 3.8.20, pytest-7.4.4, pluggy-1.4.0 -- /opt/sw/bin/python3.8
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/opt/sw/build.build/pytest-xprocess-py38-1.0.2-1/pytest-xprocess-1.0.2/.hypothesis/examples')
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /opt/sw/build.build/pytest-xprocess-py38-1.0.2-1/pytest-xprocess-1.0.2
configfile: tox.ini
plugins: xprocess-1.0.2, cov-6.0.0, hypothesis-6.42.1, flaky-3.8.1, timeout-2.3.1, benchmark-3.4.1, trio-0.8.0, xdist-3.5.0, mock-3.12.0
collected 51 items                                                                                                                                             

tests/test_callback.py::test_callback_success[s1] PASSED                                                                                                 [  1%]
tests/test_callback.py::test_callback_success[s2] PASSED                                                                                                 [  3%]
tests/test_callback.py::test_callback_success[s3] PASSED                                                                                                 [  5%]
tests/test_callback.py::test_callback_fail[s1] PASSED                                                                                                    [  7%]
tests/test_callback.py::test_callback_fail[s2] PASSED                                                                                                    [  9%]
tests/test_callback.py::test_callback_fail[s3] PASSED                                                                                                    [ 11%]
tests/test_functional_workflow.py::test_functional_work_flow FAILED                                                                                      [ 13%]
tests/test_interruption_clean_up.py::test_interruption_cleanup PASSED                                                                                    [ 15%]
tests/test_interruption_clean_up.py::test_interruption_does_not_cleanup FAILED                                                                           [ 17%]
...
__________________________________________________________________ test_functional_work_flow ___________________________________________________________________

testdir = <Testdir local('/private/tmp/pytest-of-fink-bld/pytest-4/test_functional_work_flow0')>, tcp_port = 52883

    def test_functional_work_flow(testdir, tcp_port):
        server_path = Path(__file__).parent.joinpath("server.py").absolute()
        testdir.makepyfile(
            """
            import sys
            import socket
            from xprocess import ProcessStarter
    
            def test_server(request, xprocess):
                port = %r
                data = "spam\\n"
                server_path = %r
    
                class Starter(ProcessStarter):
                    pattern = "started"
                    max_read_lines = 200
                    args = [sys.executable, server_path, port]
    
                # required so test won't hang on pytest_unconfigure
                xprocess.proc_wait_timeout = 1
    
                xprocess.ensure("server_workflow_test", Starter)
    
                with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
                    sock.connect(("localhost", port))
                    sock.sendall(bytes(data, "utf-8"))
                    received = str(sock.recv(1024), "utf-8")
                    assert received == data.upper()
        """
            % (tcp_port, str(server_path))
        )
        result = testdir.runpytest()
>       result.stdout.fnmatch_lines("*1 passed*")
E       Failed: remains unmatched: '*1 passed*'

/opt/sw/build.build/pytest-xprocess-py38-1.0.2-1/pytest-xprocess-1.0.2/tests/test_functional_workflow.py:36: Failed
--------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 155, in _multicall
    teardown[0].send(outcome)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/helpconfig.py", line 104, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_result.py", line 99, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1075, in pytest_cmdline_parse
    self.parse(args)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1425, in parse
    self._preparse(args, addopts=addopts)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1305, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_manager.py", line 415, in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 491, in register
    ret: Optional[str] = super().register(plugin, name)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_manager.py", line 168, in register
    hook._maybe_apply_history(hookimpl)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_hooks.py", line 569, in _maybe_apply_history
    res = self._hookexec(self.name, [method], kwargs, False)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "/opt/sw/lib/python3.8/site-packages/pytest_benchmark/plugin.py", line 254, in pytest_addhooks
    method(hookspec)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_manager.py", line 256, in add_hookspecs
    spec_opts = self.parse_hookspec_opts(module_or_class, name)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 471, in parse_hookspec_opts
    opts = _get_legacy_hook_marks(  # type: ignore[assignment]
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 376, in _get_legacy_hook_marks
    warn_explicit_for(cast(FunctionType, method), message)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/warning_types.py", line 170, in warn_explicit_for
    raise type(w)(f"{w}\n at {filename}:{lineno}") from None
pytest.PytestDeprecationWarning: The hookspec pytest_benchmark_generate_commit_info uses old-style configuration options (marks or attributes).
Please use the pytest.hookspec(firstresult=True) decorator instead
 to configure the hooks.
 See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
 at /opt/sw/lib/python3.8/site-packages/pytest_benchmark/hookspec.py:48

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sw/lib/python3.8/site-packages/_pytest/pytester.py", line 1172, in runpytest_inprocess
    reprec = self.inline_run(*args, **kwargs)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/pytester.py", line 1137, in inline_run
    ret = main([str(x) for x in args], plugins=plugins)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 150, in main
    config = _prepareconfig(args, plugins)
  File "/opt/sw/lib/python3.8/site-packages/_pytest/config/__init__.py", line 331, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 159, in _multicall
    _warn_teardown_exception(hook_name, teardown[1], e)
  File "/opt/sw/lib/python3.8/site-packages/pluggy/_callers.py", line 49, in _warn_teardown_exception
    warnings.warn(PluggyTeardownRaisedWarning(msg), stacklevel=5)
pluggy.PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
PytestDeprecationWarning: The hookspec pytest_benchmark_generate_commit_info uses old-style configuration options (marks or attributes).
Please use the pytest.hookspec(firstresult=True) decorator instead
 to configure the hooks.
 See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
 at /opt/sw/lib/python3.8/site-packages/pytest_benchmark/hookspec.py:48
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
______________________________________________________________ test_interruption_does_not_cleanup ______________________________________________________________

testdir = <Testdir local('/private/tmp/pytest-of-fink-bld/pytest-4/test_interruption_does_not_cleanup0')>, tcp_port = 52885

    def test_interruption_does_not_cleanup(testdir, tcp_port):
        server_path = Path(__file__).parent.joinpath("server.py").absolute()
        testdir.makepyfile(
            """
            import sys
            import socket
            from xprocess import ProcessStarter
    
            def test_servers_start(request, xprocess):
                port = %r
                server_path = %r
    
                class Starter(ProcessStarter):
                    pattern = "started"
                    args = [sys.executable, server_path, port]
    
                xprocess.ensure("server_test_interrupt_no_terminate", Starter)
    
                raise KeyboardInterrupt
            """
            % (tcp_port, str(server_path))
        )
        result = testdir.runpytest_subprocess()
        result.stdout.fnmatch_lines("*KeyboardInterrupt*")
        result = testdir.runpytest("--xshow")
>       result.stdout.fnmatch_lines("*LIVE*")
E       Failed: remains unmatched: '*LIVE*'

/opt/sw/build.build/pytest-xprocess-py38-1.0.2-1/pytest-xprocess-1.0.2/tests/test_interruption_clean_up.py:58: Failed
--------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------
running: /opt/sw/bin/python3.8 -mpytest --basetemp=/private/tmp/pytest-of-fink-bld/pytest-4/test_interruption_does_not_cleanup0/runpytest-0
     in: /private/tmp/pytest-of-fink-bld/pytest-4/test_interruption_does_not_cleanup0
...


**Expected behavior**
All tests should pass.


**Environment (please complete the following information):**
 - macOS 10.14.6
 - python 3.8.20 and 3.10.19
 - pytest-xprocess version 0.23.0 and 1.0.2

**Additional context**
This looks identical to #113 which was theoretically fixed by #114, but those were against 0.20.0 4 years ago, and 1.0.2 has the fix from #114. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions