I just started using pytest with pytest-xdist, to execute tests on remote hosts.
the remote host (windows) are using the socketserver.py module found on https://pytest.org/latest/xdist.html
my problem is that it seems like each time I execute a test, the socketserver will create a new pyexecnetcache directory inside the previous pyexecnetcache directory and fail with the following error message:
=================================== ERRORS ====================================
_______________________ ERROR collecting test_sample.py _______________________
import file mismatch:
imported module 'test_sample' has this __file__ attribute:
C:\pyexecnetcache\test_sample.py
which is not the same as the test file we want to collect:
C:\pyexecnetcache\pyexecnetcache\test_sample.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test
file modules
the test is executed by:
py.test -d --tx socket=myhost:8888 --rsyncdir test_sample.py test_sample.py
How do I remove the cache after each run?
I have tried added the following to the socketserver.py:
import sys
sys.dont_write_bytecode = True
@bjarneMichelsen
well, there is another options to try... in windows you can try to set this direcly on source like..
import sys
sys.dont_write_bytecode = True
now, for the -B option.. you can try to export the variable PYTHONDONTWRITEBYTECODE=1 instead set a python flag
it is describe on [python docs]( https://docs.python.org/2/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE)