pytest-xdist icon indicating copy to clipboard operation
pytest-xdist copied to clipboard

Resource warnings

Open jgosmann opened this issue 8 years ago • 3 comments

When running pytest with xdist I get a bunch of ResourceWarnings. To reproduce:

touch empty.py
pytest -n 2 empty.py

which produces

=============================================================== test session starts ================================================================
platform linux -- Python 3.6.1, pytest-3.2.5, py-1.5.2, pluggy-0.4.0
rootdir: /home/jgosmann, inifile:
plugins: xdist-1.20.1, forked-0.2
gw0 [0] / gw1 [0]
scheduling tests via LoadScheduling
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=1 mode='w' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=1 mode='w' encoding='UTF-8'>

=========================================================== no tests ran in 0.33 seconds ===========================================================

wheras

pytest empty.py

produces no warnings

=============================================================== test session starts ================================================================
platform linux -- Python 3.6.1, pytest-3.2.5, py-1.5.2, pluggy-0.4.0
rootdir: /home/jgosmann, inifile:
plugins: xdist-1.20.1, forked-0.2
collected 0 items                                                                                                                                   

=========================================================== no tests ran in 0.00 seconds ===========================================================

Relevant version numbers are listed in the console output.

jgosmann avatar Nov 16 '17 19:11 jgosmann

This is still happening and still annoying. Unfortunately I have no idea why 😭

Zac-HD avatar Nov 14 '19 05:11 Zac-HD

I'm also seeing this, only on OSX. The warnings don't occur when I specify --forked or -n 0 interestingly. I think these warnings are harmless though.

benjeffery avatar May 04 '22 13:05 benjeffery

I still see this on Linux if PYTHONWARNINGS=d is set. If I turn that off, then the warnings are not displayed.

leducvin avatar Jul 27 '23 16:07 leducvin