我刚开始使用 pytest 和 pytest-xdist,在远程主机上执行测试。
远程主机(Windows)正在使用https://pytest.org/latest/xdist.html上的 socketserver.py 模块
我的问题是,似乎每次执行测试时,socketserver 都会在先前的pyexecnetcache目录中创建一个新的pyexecnetcache目录,并失败并显示以下错误消息:
=================================== 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
测试由以下人员执行:
py.test -d --tx socket=myhost:8888 --rsyncdir test_sample.py test_sample.py
每次运行后如何删除缓存?
我尝试将以下内容添加到 socketserver.py:
import sys
sys.dont_write_bytecode = True