Open kalidasya opened 6 years ago
Hi @kalidasya, sorry for the delay.
I can reproduce the issue but I can't tell right now what might be the problem; I get the error even when I use --assert=plain
(which removes the custom import hook).
@nicoddemus no worries, thank you for looking into it!
Hi @kalidasya I had a similar issue before with exactly that KeyError for importing the conftest.py.
I fixed it with the following command:
find . -name \*.pyc -delete
Thanks @Reinaard, that fixed it for me too:
docker-compose run web find . -name \*.pyc -delete
(... where web
is the docker-compose service alias for my container)
I somehow missed the notifications, will try it again
still have trouble with it, I will update the ticket when I figured out something new. I delete all pyc file, also changed from socketsever to ssh, also added the test files in the container and not mount them
Hi,
system and software info:
centos
7.2python
3.6.3pytest
3.3.1I am facing an issue when I try to manipulate
sys.path
inconftest.py
(conftest file in project root). It seems it does not have an effect and related imports will fail afterwards. Moving the conftest into the test folder works the same.I have the following structure:
The project itself is an integration test framework so it is not the system under test, the
src
folder contains util functions.I run the test with
py.test scripts2/test.py -s
from root The content oftest.py
:content of
conftest.py
:content of
util.py
:if I have the conftest.py and run the pytest command I get the following error:
if I remove conftest.py and enable the sys.path manipulation in the test itself, it works. I cannot use this workaround as my real test framework is more complex and there are many tests in it. I also tried a baked dynamic import with
importlibs
that seems to work to a certain extend but some test files will still fail to import things (I tried only in the real complex project):For this simple example this solves the problem:
The bigger picture. I discovered this issue while I was working on an xdist + docker setup where the docker container has the socket server implementation of
execnet
. I kept getting this error even if thepyexecnetcache
had the correct data in the container. I was able to import things viaimp
orimportlib
, so I was sure its not related to missing files or file rights. I started to narrow down the problem as I was not sure ifexecnet
orxdist
orpytest
is the root cause, and this is how I ended up with the smallest/simplest reproduction of the problem.