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

INTERNALERROR with pytest-sugar==0.9.3 and pytest-testmon==1.0.2 #154

Closed voidus closed 2 years ago

voidus commented 4 years ago

Having both installed causes pytest to error out quickly. This only happens when both testmon and sugar are installed, so I'm posting this in both repos. The pytest-sugar issue is at https://github.com/Teemu/pytest-sugar/issues/200.

Let me know if there is anything I can do to help solve this.

Test script

cat > reproduce-sugar-testmon.sh <<'HERE'
#!/bin/bash
set -x -e

VENV="$(mktemp -d --suffix .PYTEST_SUGAR_TESTMON)"

cleanup() {
    rm -rf "$VENV"
}
trap cleanup EXIT

python3 -m venv "$VENV"
. "${VENV}/bin/activate"

pip install pytest-sugar pytest-testmon

echo '===== VERSIONS ====='
pip freeze
echo '=====  OUTPUT  ====='

pytest --testmon

HERE

chmod +x reproduce-sugar-testmon.sh && ./reproduce-sugar-testmon.sh

Output

++ mktemp -d --suffix .PYTEST_SUGAR_TESTMON                                                                                                                                                                                                                                       
+ VENV=/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON
+ trap cleanup EXIT
+ python3 -m venv /tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON
+ . /tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/bin/activate
++ deactivate nondestructive
++ '[' -n '' ']'                                                                                                                         
++ '[' -n '' ']'                     
++ '[' -n /bin/bash -o -n '' ']'                           
++ hash -r                         
++ '[' -n '' ']'                                                
++ unset VIRTUAL_ENV                                                                                                                     
++ '[' '!' nondestructive = nondestructive ']'                    
++ VIRTUAL_ENV=/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON                                                                                  
++ export VIRTUAL_ENV                                            
++ _OLD_VIRTUAL_PATH=/home/voyd/Coding/pytest-sugar-testmon-interaction/env/bin:/home/voyd/perl5/bin:/home/voyd/.nix-profile/bin:/home/voyd/.bin:/home/voyd/.local/bin:/opt/google-cloud-sdk/bin:/home/voyd/.bin:/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/local
/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
++ PATH=/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/bin:/home/voyd/Coding/pytest-sugar-testmon-interaction/env/bin:/home/voyd/perl5/bin:/home/voyd/.nix-profile/bin:/home/voyd/.bin:/home/voyd/.local/bin:/opt/google-cloud-sdk/bin:/home/voyd/.bin:/opt/google-cloud-sdk/bin:/usr/lo
cal/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
++ export PATH                                                                                                                           
++ '[' -n '' ']'                                                                                                                         
++ '[' -z '' ']'                                                                                                                         
++ _OLD_VIRTUAL_PS1=                          
++ '[' 'x(tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON) ' '!=' x ']'                                                                              
++ PS1='(tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON) '     
++ export PS1
++ '[' -n /bin/bash -o -n '' ']'
++ hash -r
+ pip install pytest-sugar pytest-testmon
Collecting pytest-sugar
  Using cached https://files.pythonhosted.org/packages/ba/35/edf24df4b2fe7d9005bdb9d166c18ae9cefd8b664e7fb2c8dfb7bc9db184/pytest-sugar-0.9.3.tar.gz
Collecting pytest-testmon
  Using cached https://files.pythonhosted.org/packages/87/ea/9e2e77311e584aca947b5fdfe7fa6192cf39658d475d0e2017bf4d628491/pytest_testmon-1.0.2-py3-none-any.whl
Collecting pytest>=2.9 (from pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/9f/f3/0a83558da436a081344aa6c8b85ea5b5f05071214106036ce341b7769b0b/pytest-5.4.3-py3-none-any.whl
Collecting termcolor>=1.1.0 (from pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting packaging>=14.1 (from pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/46/19/c5ab91b1b05cfe63cccd5cfc971db9214c6dd6ced54e33c30d5af1d2bc43/packaging-20.4-py2.py3-none-any.whl
Collecting coverage<6,>=4 (from pytest-testmon)
  Using cached https://files.pythonhosted.org/packages/52/38/53a28fcbe77f56f92d45f9961feca85caebe7424b63a10b07aa8607a4f8d/coverage-5.1-cp38-cp38-manylinux1_x86_64.whl
Collecting wcwidth (from pytest>=2.9->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/ef/94/a17155b400812f0558093c6fb99f92ba823e24757d5884e3ec60f5e81319/wcwidth-0.2.4-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest>=2.9->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting pluggy<1.0,>=0.12 (from pytest>=2.9->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/a0/28/85c7aa31b80d150b772fbe4a229487bc6644da9ccb7e427dd8cc60cb8a62/pluggy-0.13.1-py2.py3-none-any.whl
Collecting py>=1.5.0 (from pytest>=2.9->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/ae/12/76710702ccf77dab01246ecb55fbe43175131c0738d0be29f3de50d31071/py-1.8.2-py2.py3-none-any.whl
Collecting more-itertools>=4.0.0 (from pytest>=2.9->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/ef/9b/6c35ec5483710492e21252465160ee508170159f7e0e2d6cd769022f52f6/more_itertools-8.4.0-py3-none-any.whl
Collecting pyparsing>=2.0.2 (from packaging>=14.1->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl
Collecting six (from packaging>=14.1->pytest-sugar)
  Using cached https://files.pythonhosted.org/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl
Installing collected packages: pyparsing, six, packaging, wcwidth, attrs, pluggy, py, more-itertools, pytest, termcolor, pytest-sugar, coverage, pytest-testmon
  Running setup.py install for termcolor ... done
  Running setup.py install for pytest-sugar ... done
Successfully installed attrs-19.3.0 coverage-5.1 more-itertools-8.4.0 packaging-20.4 pluggy-0.13.1 py-1.8.2 pyparsing-2.4.7 pytest-5.4.3 pytest-sugar-0.9.3 pytest-testmon-1.0.2 six-1.15.0 termcolor-1.1.0 wcwidth-0.2.4
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.                                                                                                                                                                                                        
+ echo '===== VERSIONS ====='                                                                                                                                                                                                                                                     
===== VERSIONS =====                                                                                                                                                                                                                                                              
+ pip freeze                                                                                                                                                                                                                                                                      
attrs==19.3.0                                                                                                                            
coverage==5.1                                                                                                                                                                                                                                                                     
more-itertools==8.4.0                                                                                                                    
packaging==20.4                                                                                                                                                                                                                                                                   
pluggy==0.13.1                                                                                                                                                                                                                                                                    
py==1.8.2                                                                                                                                
pyparsing==2.4.7                                                                                                                                                                                                                                                                  
pytest==5.4.3                             
pytest-sugar==0.9.3                                                                                                                                                                                                                                                               
pytest-testmon==1.0.2                          
six==1.15.0                                                                                                                                                                                                                                                                       
termcolor==1.1.0                                                                                                                         
wcwidth==0.2.4                                                                                                                                                                                                                                                                    
+ echo '=====  OUTPUT  ====='                  
=====  OUTPUT  =====                                                                                                                                                                                                                                                              
+ pytest --testmon                                        
Test session starts (platform: linux, Python 3.8.3, pytest 5.4.3, pytest-sugar 0.9.3)                                                                                                                                                                                             
testmon: new DB, environment: default                    
rootdir: /home/voyd/Coding/pytest-sugar-testmon-interaction                                                                                                                                                                                                                       
plugins: testmon-1.0.2, sugar-0.9.3                          
collecting ... INTERNALERROR> Traceback (most recent call last):                                                                                                                                                                                                                  
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0                                                                                                                                                                                                                
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/main.py", line 246, in _main         
INTERNALERROR>     config.hook.pytest_collection(session=session)                                                                                                                                                                                                                 
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__      
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)                                                                                                                                                                                                      
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec                                                                                                                                             
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)                                                                                                                                                                                                             
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>                                                                                                                                              
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(                                                                                                                                                                                           
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall  
INTERNALERROR>     return outcome.get_result()                                                                                                                                                                                                                                    
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result   
INTERNALERROR>     raise ex[1].with_traceback(ex[2])                                                                                     
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall  
INTERNALERROR>     res = hook_impl.function(*args)  
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/main.py", line 257, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/main.py", line 454, in perform_collect
INTERNALERROR>     hook.pytest_collection_modifyitems(
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)                                                                                                                                                                                                      
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)                                                                                                                                                                                                             
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(                                                                                                                                                                                           
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()                                                                                                                                                                                                                                    
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])                                                                                                                                                                                                                              
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)                                                                                                                                                                                                                                
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/testmon/pytest_testmon.py", line 318, in pytest_collection_modifyitems
INTERNALERROR>     session.config.hook.pytest_deselected(                                                                                                                                                                                                                         
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)                                                                                                                                                                                                      
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)                                                                                                                                                                                                             
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>   
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(                                                                                                                                                                                           
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()                                                                                                                                                                                                                                    
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])                                                                                                                                                                                                                              
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)                                                                                                                                                                                                                                
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/terminal.py", line 432, in pytest_deselected                                                                                                                                  
INTERNALERROR>     self._add_stats("deselected", items)                                                                                  
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/terminal.py", line 403, in _add_stats
INTERNALERROR>     self._set_main_color()
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/terminal.py", line 1091, in _set_main_color
INTERNALERROR>     self._main_color = self._determine_main_color(bool(unknown_types))
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/terminal.py", line 1078, in _determine_main_color
INTERNALERROR>     elif "passed" in stats or not self._is_last_item: 
INTERNALERROR>   File "/tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON/lib/python3.8/site-packages/_pytest/terminal.py", line 497, in _is_last_item
INTERNALERROR>     return len(self._progress_nodeids_reported) == self._session.testscollected
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'testscollected'

Results (0.36s):
+ cleanup
+ rm -rf /tmp/tmp.DvrZxEyQLm.PYTEST_SUGAR_TESTMON
./reproduce-sugar-testmon.sh  3,43s user 0,32s system 88% cpu 4,256 total
tarpas commented 2 years ago

This has been fixed in pytest-sugar long ago.