Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest 7: test_high_number_of_file_descriptors causes next test to fail #502

Closed
1 of 3 tasks
bnavigator opened this issue Apr 2, 2022 · 1 comment Β· Fixed by #703
Closed
1 of 3 tasks

Pytest 7: test_high_number_of_file_descriptors causes next test to fail #502

bnavigator opened this issue Apr 2, 2022 · 1 comment Β· Fixed by #703
Labels
bug Something is broken triage

Comments

@bnavigator
Copy link

❓ I'm submitting a ...

  • 🐞 bug report
  • 🐣 feature request
  • ❓ question about the decisions made in the repository

🐞 Describe the bug. What is the current behavior?
When upgrading to pytest 7, the test suite fails with an error for setting up the first test of test_ssl.py, which is usually run after test_server.py::test_high_numer_of_file_descriptors.

πŸ’‘ To Reproduce

  1. Install pytest >= 7.1.1
  2. replace --numprocesses=auto in pytest.ini with 1 or delete the flag.
  3. Run pytest

πŸ’‘ Expected behavior
Successful test suite

πŸ“‹ Details

abuild@skylab:~/rpmbuild/BUILD/cheroot-8.6.0> python3 -m pytest -x -n 1
================================================================================================================================= test session starts ==================================================================================================================================
platform linux -- Python 3.8.12, pytest-7.1.1, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/abuild/rpmbuild/BUILD/cheroot-8.6.0, configfile: pytest.ini, testpaths: cheroot/test/
plugins: forked-1.3.0, xdist-2.5.0, mock-3.6.1
[gw0] linux Python 3.8.12 cwd: /home/abuild/rpmbuild/BUILD/cheroot-8.6.0
[gw0] Python 3.8.12 (default, Aug 31 2021, 01:23:42) [GCC]
gw0 [157]
scheduling tests via LoadScheduling

...
[gw0] [ 64%] PASSED cheroot/test/test_server.py::test_peercreds_unix_sock_with_lookup[file] 
cheroot/test/test_server.py::test_high_number_of_file_descriptors[1024] Exception ignored in: <socket.socket fd=1027, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 38954, 0, 0), raddr=('::1', 59583, 0, 0)>
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/_pytest/runner.py", line 136, in runtestprotocol
    item.funcargs = None  # type: ignore[attr-defined]
ResourceWarning: unclosed <socket.socket fd=1027, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 38954, 0, 0), raddr=('::1', 59583, 0, 0)>

[gw0] [ 65%] PASSED cheroot/test/test_server.py::test_high_number_of_file_descriptors[1024] 
cheroot/test/test_server.py::test_high_number_of_file_descriptors[2048] Exception ignored in: <socket.socket fd=2051, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 35316, 0, 0), raddr=('::1', 44913, 0, 0)>
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/_pytest/runner.py", line 136, in runtestprotocol
    item.funcargs = None  # type: ignore[attr-defined]
ResourceWarning: unclosed <socket.socket fd=2051, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 35316, 0, 0), raddr=('::1', 44913, 0, 0)>

[gw0] [ 66%] PASSED cheroot/test/test_server.py::test_high_number_of_file_descriptors[2048] 
cheroot/test/test_ssl.py::test_ssl_adapters[builtin] 
[gw0] [ 66%] ERROR cheroot/test/test_ssl.py::test_ssl_adapters[builtin] 

======================================================================================================================================== ERRORS ========================================================================================================================================
_____________________________________________________________________________________________________________________ ERROR at setup of test_ssl_adapters[builtin] _____________________________________________________________________________________________________________________
[gw0] linux -- Python 3.8.12 /usr/bin/python3

cls = <class '_pytest.runner.CallInfo'>, func = <function call_runtest_hook.<locals>.<lambda> at 0x7fd354fec160>, when = 'setup', reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

cls        = <class '_pytest.runner.CallInfo'>
duration   = 0.00038953999955992913
excinfo    = <ExceptionInfo AssertionError('previous item was not torn down properly') tblen=6>
func       = <function call_runtest_hook.<locals>.<lambda> at 0x7fd354fec160>
precise_start = 5120.715909499
precise_stop = 5120.716299039
reraise    = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
result     = None
start      = 1648897978.8972251
stop       = 1648897978.8976173
when       = 'setup'

/usr/lib/python3.8/site-packages/_pytest/runner.py:338: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.8/site-packages/_pytest/runner.py:259: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
        ihook      = <_HookCaller 'pytest_runtest_setup'>
        item       = <Function test_ssl_adapters[builtin]>
        kwds       = {}
/usr/lib/python3.8/site-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
        argname    = 'item'
        args       = ()
        firstresult = False
        kwargs     = {'item': <Function test_ssl_adapters[builtin]>}
        self       = <_HookCaller 'pytest_runtest_setup'>
/usr/lib/python3.8/site-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
        firstresult = False
        hook_name  = 'pytest_runtest_setup'
        kwargs     = {'item': <Function test_ssl_adapters[builtin]>}
        methods    = [<HookImpl plugin_name='nose', plugin=<module '_pytest.nose' from '/usr/lib/python3.8/site-packages/_pytest/nose.py'>>...=None>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x7fd357f1a5e0>>, ...]
        self       = <_pytest.config.PytestPluginManager object at 0x7fd35dbb1b50>
/usr/lib/python3.8/site-packages/_pytest/runner.py:154: in pytest_runtest_setup
    item.session._setupstate.setup(item)
        item       = <Function test_ssl_adapters[builtin]>
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_pytest.runner.SetupState object at 0x7fd357ecb220>, item = <Function test_ssl_adapters[builtin]>

    def setup(self, item: Item) -> None:
        """Setup objects along the collector chain to the item."""
        needed_collectors = item.listchain()
    
        # If a collector fails its setup, fail its entire subtree of items.
        # The setup is not retried for each item - the same exception is used.
        for col, (finalizers, exc) in self.stack.items():
>           assert col in needed_collectors, "previous item was not torn down properly"
E           AssertionError: previous item was not torn down properly

col        = <Module test_server.py>
exc        = None
finalizers = [<bound method Node.teardown of <Module test_server.py>>]
item       = <Function test_ssl_adapters[builtin]>
needed_collectors = [<Session cheroot-8.6.0 exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=157>, <Package test>, <Module test_ssl.py>, <Function test_ssl_adapters[builtin]>]
self       = <_pytest.runner.SetupState object at 0x7fd357ecb220>

/usr/lib/python3.8/site-packages/_pytest/runner.py:482: AssertionError
--------------------------------------------------------------------------------------------- generated xml file: /home/abuild/rpmbuild/BUILD/cheroot-8.6.0/.test-results/pytest/test.xml ----------------------------------------------------------------------------------------------
================================================================================================================================= slowest 10 durations =================================================================================================================================
4.01s call     cheroot/test/test_conn.py::test_HTTP11_Timeout_after_request
3.43s call     cheroot/test/test_conn.py::test_keepalive_conn_management
2.00s call     cheroot/test/test_conn.py::test_HTTP11_Timeout[True]
2.00s call     cheroot/test/test_conn.py::test_HTTP11_Timeout[False]
1.04s call     cheroot/test/test_conn.py::test_invalid_selected_connection
0.60s call     cheroot/test/test_conn.py::test_598
0.60s call     cheroot/test/test_server.py::test_server_interrupt[RuntimeError]
0.60s call     cheroot/test/test_server.py::test_server_interrupt[OSError1]
0.60s call     cheroot/test/test_server.py::test_server_interrupt[OSError0]
0.60s call     cheroot/test/test_server.py::test_server_interrupt[KeyboardInterrupt]
=============================================================================================================================== short test summary info ================================================================================================================================
XFAIL cheroot/test/test_conn.py::test_Chunked_Encoding
  Headers from earlier request leak into the request line for a subsequent request, resulting in 400 instead of 413. See cherrypy/cheroot#69 for details.
XFAIL cheroot/test/test_conn.py::test_598
  Sometimes this test fails due to low timeout. Ref: https://github.com/cherrypy/cherrypy/issues/598
XFAIL cheroot/test/test_core.py::test_large_request
  https://github.com/cherrypy/cheroot/issues/106
ERROR cheroot/test/test_ssl.py::test_ssl_adapters[builtin] - AssertionError: previous item was not torn down properly
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================================================== 101 passed, 3 xfailed, 1 error in 63.11s (0:01:03) ==================================================================================================================
abuild@skylab:~/rpmbuild/BUILD/cheroot-8.6.0> 


πŸ“‹ Environment

  • Cheroot version: 6.8.0
  • CherryPy version: N/A
  • Python version: 3.8.12 (+ 3.9 + 3.10)
  • OS: openSUSE Tumbleed Linux (Inside openbuildservive VM for rpmbuild)
@bnavigator bnavigator added bug Something is broken triage labels Apr 2, 2022
@webknjaz
Copy link
Member

webknjaz commented Oct 5, 2022

That's an incompatibility of pytest-forked and pytest 7.

webknjaz pushed a commit to webknjaz/cheroot that referenced this issue Apr 27, 2024
This plugin is incompatible with Pytest 7+, it's difficult to fix
upstream and there is no timeline for addressing that.

The patch also bumps the top version boundary of Pytest to 7.2 due
to the pinned `pytest-cov` raising warnings.

Fixes #cherrypy#502
Resolves cherrypy#511
Closes cherrypy#680
webknjaz pushed a commit to webknjaz/cheroot that referenced this issue Apr 27, 2024
This plugin is incompatible with Pytest 7+, it's difficult to fix
upstream and there is no timeline for addressing that.

The patch also bumps the top version boundary of Pytest to 7.2 due
to the pinned `pytest-cov` raising warnings.

Fixes #cherrypy#502
Resolves cherrypy#511
Closes cherrypy#680
Resolves cherrypy#681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants