0

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
  • Hmm, try to run Python with `-B`. Source: [https://bitbucket.org/pytest-dev/pytest/issues/200/disable-the-creation-of-the-__pycache__#comment-2114656](https://bitbucket.org/pytest-dev/pytest/issues/200/disable-the-creation-of-the-__pycache__#comment-2114656) – Darius May 18 '16 at 14:32
  • It didn't change anything, still creating the cache – Bjarne Michelsen May 19 '16 at 07:12

2 Answers2

0

Try to export PYTHONFLAGS variable:

export PYTHONFLAGS=-B
Ederson Badeca
  • 363
  • 1
  • 9
0

@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)

Ederson Badeca
  • 363
  • 1
  • 9