question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pytest failing silently before or during collection

See original GitHub issue

pytest is failing for some projects during or before collection.

Notice that is never makes it to collection.

Works normally when running with the xdist option --looponfail Fails whether or not xdist is installed

zdk@pc ~/devel/MyProject (master)
$ pytest
============================= test session starts =============================
platform win32 -- Python 3.6.9, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
PyQt5 5.9.2 -- Qt runtime 5.9.7 -- Qt compiled 5.9.6
rootdir: C:\Users\zdkohler\devel\MyProject, inifile: pytest.ini, testpaths: tests
plugins: cov-2.7.1, forked-1.0.2, qt-3.2.2, xdist-1.29.0
(base)
zdk@pc ~/devel/MyProject (master)
$

Running pytest with --debug

$ tail -5 pytestdebug.log
      early skip of rewriting module: urllib2 [assertion]
      early skip of rewriting module: libcooper.http.reports [assertion]
      early skip of rewriting module: libcooper.loghandler [assertion]
      early skip of rewriting module: logging.handlers [assertion]
      early skip of rewriting module: jinja2.ext [assertion]
  • output of pip list from the virtual environment you are using
Package                       Version   Location                                           
----------------------------- --------- ---------------------------------------------------
-umpy                         1.16.4    
advbumpversion                1.2.0     
alabaster                     0.7.12    
apipkg                        1.5       
appdirs                       1.4.3     
argh                          0.26.2    
arrow                         0.13.1    
asn1crypto                    0.24.0    
astroid                       2.2.5     
atomicwrites                  1.3.0     
attrs                         19.1.0    
autopep8                      1.4.4     
Babel                         2.7.0     
backcall                      0.1.0     
backports.functools-lru-cache 1.5       
backports.tempfile            1.0       
backports.weakref             1.0.post1 
bcrypt                        3.1.6     
beautifulsoup4                4.8.0     
binaryornot                   0.4.4     
bleach                        3.1.0     
bokeh                         1.3.4     
cached-property               1.5.1     
calmap                        0.0.7     
certifi                       2019.6.16 
cffi                          1.12.3    
chardet                       3.0.4     
Click                         7.0       
cloudpickle                   1.2.1     
colorama                      0.4.1     
comtypes                      1.1.7     
conda                         4.7.11    
conda-build                   3.18.9    
conda-package-handling        1.3.11    
conda-verify                  3.4.2     
constructor                   3.0.0     
cookiecutter                  1.6.0     
coverage                      4.5.3     
cryptography                  2.7       
cycler                        0.10.0    
cytoolz                       0.10.0    
dask                          2.3.0     
decorator                     4.4.0     
defusedxml                    0.6.0     
docutils                      0.15.2    
dogpile.cache                 0.7.1     
entrypoints                   0.3       
et-xmlfile                    1.0.1     
ete3                          3.1.1     
execnet                       1.6.1     
fastcache                     1.1.0     
filelock                      3.0.12    
Flask                         1.1.1     
Flask-WTF                     0.14.2    
future                        0.17.1    
glob2                         0.7       
greenlet                      0.4.15    
idna                          2.8       
imageio                       2.5.0     
imagesize                     1.1.0     
importlib-metadata            0.19      
ipykernel                     5.1.2     
ipython                       7.7.0     
ipython-genutils              0.2.0     
isodate                       0.6.0     
isort                         4.3.21    
itsdangerous                  1.1.0     
jdcal                         1.4.1     
jedi                          0.15.1    
Jinja2                        2.10.1    
jinja2-time                   0.2.0     
joblib                        0.13.2    
json5                         0.8.5     
jsonschema                    3.0.2     
jupyter-client                5.3.1     
jupyter-core                  4.5.0     
jupyterlab                    1.0.2     
jupyterlab-server             1.0.0     
keyboard                      0.13.3    
kiwisolver                    1.1.0     
lazy-object-proxy             1.4.1     
libarchive-c                  2.8       
lxml                          3.7.2     
MarkupSafe                    1.1.1     
matplotlib                    3.1.1     
mccabe                        0.6.1     
menuinst                      1.4.16    
mistune                       0.8.4     
mkl-fft                       1.0.14    
mkl-random                    1.0.2     
mkl-service                   2.0.2     
more-itertools                7.2.0     
mpmath                        1.1.0     
msgpack                       0.6.1     
nbconvert                     5.5.0     
nbformat                      4.4.0     
neovim                        0.3.1     
networkx                      2.3       
notebook                      6.0.0     
ntlm-auth                     1.4.0     
numpy                         1.16.4    
olefile                       0.46      
onnx                          1.5.0     
onnxconverter-common          1.5.3     
openpyxl                      2.6.2     
packaging                     19.1      
pandas                        0.25.0    
pandocfilters                 1.4.2     
paramiko                      2.4.2     
parso                         0.5.1     
pathtools                     0.1.2     
pickleshare                   0.7.5     
Pillow                        6.1.0     
pip                           19.2.2    
pkginfo                       1.5.0.1   
pluggy                        0.12.0    
plumbum                       1.6.7     
poyo                          0.5.0     
prometheus-client             0.7.1     
prompt-toolkit                2.0.9     
protobuf                      3.9.1     
psutil                        5.6.3     
py                            1.8.0     
pyasn1                        0.4.6     
pycodestyle                   2.5.0     
pycosat                       0.6.3     
pycparser                     2.19      
Pygments                      2.4.2     
pylint                        2.3.1     
PyNaCl                        1.3.0     
pynvim                        0.3.2     
pyodbc                        4.0.27    
pyOpenSSL                     19.0.0    
pyparsing                     2.4.2     
pyqtgraph                     0.10.0    
pyrsistent                    0.14.11   
PySocks                       1.7.0     
pytest                        5.1.2     
pytest-cov                    2.7.1     
pytest-forked                 1.0.2     
pytest-qt                     3.2.2     
pytest-xdist                  1.29.0    
python-dateutil               2.8.0     
pythonnet                     2.4.0     
pytz                          2019.2    
PyWavelets                    1.0.3     
pywin32                       223       
pywinpty                      0.5.5     
PyYAML                        5.1.2     
pyzmq                         17.0.0    
requests                      2.22.0    
requests-ntlm                 1.1.0     
requests-toolbelt             0.9.1     
rope                          0.14.0    
ruamel-yaml                   0.15.46   
scikit-image                  0.15.0    
scikit-learn                  0.21.2    
scipy                         1.3.1     
Send2Trash                    1.5.0     
setuptools                    41.0.1    
sip                           4.19.13   
six                           1.12.0    
skl2onnx                      1.5.0     
snakeviz                      2.0.1     
snowballstemmer               1.9.0     
soupsieve                     1.9.2     
Sphinx                        2.1.2     
sphinxcontrib-applehelp       1.0.1     
sphinxcontrib-devhelp         1.0.1     
sphinxcontrib-htmlhelp        1.0.2     
sphinxcontrib-jsmath          1.0.1     
sphinxcontrib-qthelp          1.0.2     
sphinxcontrib-serializinghtml 1.1.3     
SQLAlchemy                    1.3.7     
sympy                         1.4       
terminado                     0.8.2     
testpath                      0.4.2     
toolz                         0.10.0    
tornado                       6.0.3     
tqdm                          4.32.1    
traitlets                     4.3.2     
typed-ast                     1.3.4     
typing                        3.7.4     
typing-extensions             3.7.4     
urllib3                       1.24.2    
watchdog                      0.9.0     
wcwidth                       0.1.7     
webencodings                  0.5.1     
Werkzeug                      0.15.5    
wfastcgi                      3.0.0     
wheel                         0.33.4    
whichcraft                    0.6.0     
win-inet-pton                 1.1.0     
wincertstore                  0.2       
wrapt                         1.11.2    
WTForms                       2.2.1     
xlrd                          1.2.0     
XlsxWriter                    1.1.8     
xlwings                       0.15.8    
zeep                          3.4.0     
zipp                          0.5.2     

pytest and operating system versions Windows 10, Python 3.6, pytest 5.1.2

$ pytest --version
pytest will always run as Dev environment/db
This is pytest version 5.1.2, imported from C:\ProgramData\Anaconda3\lib\site-packages\pytest.py
setuptools registered plugins:
  pytest-cov-2.7.1 at C:\ProgramData\Anaconda3\lib\site-packages\pytest_cov\plugin.py
  pytest-forked-1.0.2 at C:\ProgramData\Anaconda3\lib\site-packages\pytest_forked\__init__.py
  pytest-qt-3.2.2 at C:\ProgramData\Anaconda3\lib\site-packages\pytestqt\plugin.py
  pytest-xdist-1.29.0 at C:\ProgramData\Anaconda3\lib\site-packages\xdist\plugin.py
  pytest-xdist-1.29.0 at C:\ProgramData\Anaconda3\lib\site-packages\xdist\looponfail.py

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
simsongcommented, Feb 22, 2021

I was dealing with a very similar problem. It turns out that I had an os.execl() in my code that was causing the problem. I had to set up pytest to set an environment variable and have my code not exec if it was running under pytest.

0reactions
Zac-HDcommented, Oct 24, 2019

Closing this issue as there’s nothing useful to do without a reproducing test case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What to do when a py.test hangs silently? - Stack Overflow
Not knowing what is breaking in the code, the best way is to isolate the test that is failing and set a breakpoint...
Read more >
How to capture warnings — pytest documentation
Disabling warnings summary​​ Although not recommended, you can use the --disable-warnings command-line option to suppress the warning summary entirely from the ...
Read more >
Why Do Tasks in the ThreadPoolExecutor Fail Silently
The exception() function will block until the task is done (successfully or otherwise), and you can specify a timeout in seconds for how...
Read more >
pytest-watch - PyPI
xdist offers the --looponfail (-f) option (and distributed testing options). This instead re-runs only those tests which have failed until you make them...
Read more >
1417920 - Silence pytest warnings about build system classes ...
From https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst#310-2017-05-22: > It is now possible to skip test classes from being collected by setting a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found