kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 59 forks source link

AssertionError: Expected current collector to be... #31

Open NathanUrwin opened 5 years ago

NathanUrwin commented 5 years ago
self._collectors:
  <Collector at 0x7f7a3779d8d0: CTracer>
                      <module> : /usr/local/bin/pytest @10
                          main : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @60
                _prepareconfig : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @195
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_cmdline_parse : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @654
                         parse : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @871
                     _preparse : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @826
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
 pytest_load_initial_conftests : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @99
                      __init__ : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @146
                         start : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @168
                         start : /usr/local/lib/python3.7/site-packages/pytest_cov/engine.py @159
                         erase : /usr/local/lib/python3.7/site-packages/coverage/control.py @726
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a35d7cba8: CTracer>
                      <module> : /usr/local/bin/pytest @10
                          main : /usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py @79
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
           pytest_cmdline_main : /usr/local/lib/python3.7/site-packages/_pytest/main.py @242
                  wrap_session : /usr/local/lib/python3.7/site-packages/_pytest/main.py @209
                         _main : /usr/local/lib/python3.7/site-packages/_pytest/main.py @249
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
            pytest_runtestloop : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @342
                         start : /usr/local/lib/python3.7/multiprocessing/process.py @112
                        _Popen : /usr/local/lib/python3.7/multiprocessing/context.py @223
                        _Popen : /usr/local/lib/python3.7/multiprocessing/context.py @277
                      __init__ : /usr/local/lib/python3.7/multiprocessing/popen_fork.py @20
                       _launch : /usr/local/lib/python3.7/multiprocessing/popen_fork.py @74
                    _bootstrap : /usr/local/lib/python3.7/multiprocessing/process.py @290
            _run_after_forkers : /usr/local/lib/python3.7/multiprocessing/util.py @132
         multiprocessing_start : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @23
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a35ce4ef0: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @81
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a35d68e10: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @81
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @246
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a34483f60: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @74
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a34483898: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @74
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a34446ac8: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @74
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
  <Collector at 0x7f7a344b8be0: CTracer>
                    _bootstrap : /usr/local/lib/python3.7/threading.py @885
              _bootstrap_inner : /usr/local/lib/python3.7/threading.py @917
                           run : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @74
                      run_test : /usr/local/lib/python3.7/site-packages/pytest_parallel/__init__.py @51
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
       pytest_runtest_protocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @78
               runtestprotocol : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @87
               call_and_report : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @173
             call_runtest_hook : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                     from_call : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @226
                      <lambda> : /usr/local/lib/python3.7/site-packages/_pytest/runner.py @198
                      __call__ : /usr/local/lib/python3.7/site-packages/pluggy/hooks.py @289
                     _hookexec : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @68
                      <lambda> : /usr/local/lib/python3.7/site-packages/pluggy/manager.py @62
                    _multicall : /usr/local/lib/python3.7/site-packages/pluggy/callers.py @187
          pytest_runtest_setup : /usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py @287
                          init : /usr/local/lib/python3.7/site-packages/pytest_cov/embed.py @67
                          load : /usr/local/lib/python3.7/site-packages/coverage/control.py @675
                         _init : /usr/local/lib/python3.7/site-packages/coverage/control.py @266
                      __init__ : /usr/local/lib/python3.7/site-packages/coverage/collector.py @107
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/util.py", line 265, in _run_finalizers
    finalizer()
  File "/usr/local/lib/python3.7/multiprocessing/util.py", line 189, in __call__
    res = self._callback(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/pytest_cov/embed.py", line 83, in cleanup
    _cleanup(cov)
  File "/usr/local/lib/python3.7/site-packages/pytest_cov/embed.py", line 76, in _cleanup
    cov.stop()
  File "/usr/local/lib/python3.7/site-packages/coverage/control.py", line 707, in stop
    self.collector.stop()
  File "/usr/local/lib/python3.7/site-packages/coverage/collector.py", line 328, in stop
    "Expected current collector to be %r, but it's %r" % (self, self._collectors[-1])
AssertionError: Expected current collector to be <Collector at 0x7f7a35d7cba8: CTracer>, but it's <Collector at 0x7f7a344b8be0: CTracer>
NathanUrwin commented 5 years ago

Looking at the traceback... looks like this plugin and the pytest-cov plugin do not play nice together?

JohnTheodore commented 5 years ago

I have the same issue. pytest-cov and pytest-parallel don't seem to work together with all the options?

Here is my diff: https://github.com/JohnTheodore/city_comparison/pull/22/files

You can clone my repo to have everything you need to reproduce this. Check out my .travis.yml

The travis build is here: https://travis-ci.org/JohnTheodore/city_comparison/builds/541660793?utm_source=github_status&utm_medium=notification

JohnTheodore commented 5 years ago

note, pytest-xdist seems to work with pytest-cov, also xdist doesn't spam stdout on the tests, and parallel spams stdout (even on successful tests). here is the xdist travis build: https://travis-ci.org/JohnTheodore/city_comparison/builds/541681700?utm_source=github_status&utm_medium=notification