tarpas / pytest-testmon

Selects tests affected by changed files. Executes the right tests first. Continuous test runner when used with pytest-watch.
https://testmon.org
MIT License
800 stars 54 forks source link

`pytest --testmon --forked` leads to AttributeError #184

Closed janbernloehr closed 1 year ago

janbernloehr commented 2 years ago

We experience issues when running pytest --testmon together with pytest-forked. A typical stack trace looks like this: The issue seems that coverage's configure already calls should_trace but at this point, self.plugins is still initialized as an empty list hence resulting in the error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 268, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 322, in _main
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 347, in pytest_runtestloop
    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 34, in _multicall
    next(gen)  # first yield
  File "/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/testmon/pytest_testmon.py", line 260, in pytest_runtest_protocol
    self.testmon.start()
  File "/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/testmon/testmon_core.py", line 347, in start
    self.cov.start()
  File "/usr/local/lib/python3.8/dist-packages/coverage/control.py", line 575, in start
    self._init_for_start()
  File "/usr/local/lib/python3.8/dist-packages/coverage/control.py", line 530, in _init_for_start
    self._inorout.configure(self.config)
  File "/usr/local/lib/python3.8/dist-packages/coverage/inorout.py", line 224, in configure
    self.omit = prep_patterns(config.run_omit)
  File "/usr/local/lib/python3.8/dist-packages/coverage/control.py", line 344, in _should_trace
    disp = self._inorout.should_trace(filename, frame)
  File "/usr/local/lib/python3.8/dist-packages/coverage/inorout.py", line 367, in should_trace
    for plugin in self.plugins.file_tracers:
AttributeError: 'list' object has no attribute 'file_tracers'