abalkin / pytest-leaks

A pytest plugin to trace resource leaks.
https://abalkin.github.io/pytest-leaks
Other
115 stars 4 forks source link

Does not work on pytest 6. #38

Open proofit404 opened 3 years ago

proofit404 commented 3 years ago

Instead of report summary it produce strange traceback with pytest internals.

memoryleak run-test: commands[0] | python3.8d -m pytest -c /dev/null --leaks=:
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.5, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/memoryleak/.pytest_cache
rootdir: /home/proofit404/data/generics, configfile: ../../../../dev/null
plugins: leaks-0.3.1
collected 155 items

tests/test_configuration.py LFEEEEEEEEEFEEEEEEEEEEEEEEEEEE                                                                                                            [ 19%]
tests/test_dependencies.py EEEEE                                                                                                                                      [ 22%]
tests/test_private.py EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE                        [100%]Traceback (most recent call last):
  File "/home/proofit404/.pyenv/versions/3.8.5-debug/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/proofit404/.pyenv/versions/3.8.5-debug/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/config/__init__.py", line 187, in console_main
    code = main()
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/config/__init__.py", line 164, in main
    ret = config.hook.pytest_cmdline_main(
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/main.py", line 306, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/main.py", line 294, in wrap_session
    config.hook.pytest_sessionfinish(
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/terminal.py", line 794, in pytest_sessionfinish
    outcome.get_result()
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/runner.py", line 104, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/runner.py", line 413, in teardown_all
    self._teardown_with_finalization(key)
  File "/home/proofit404/data/generics/.tox/memoryleak/lib/python3.8/site-packages/_pytest/runner.py", line 407, in _teardown_with_finalization
    assert colitem in self.stack
AssertionError
jdavid commented 3 years ago

I've used pytest-leaks with pytest 6.2.4 and didn't see this error (it worked fine, except for issue #36)

seberg commented 2 years ago

Hmm, I just realized that I am still using pytest 5.4 because of these difficulties. We may have to look into fixing things up for pytest 7, I guess (I don't care about compat with all versions, so long I can run it over the numpy test suite just fine every half year).

(I realizes that "we may have to look into", probably means that I should try to do that...)