Pytest: conftest.py identified in the host and guest when running Docker

Created on 4 Jun 2019  路  3Comments  路  Source: pytest-dev/pytest

I am trying to use Docker to run our test cases.
I am sharing the git repo volume between host and guest.
I am also using pytest inside of tox.

When running pytext (from tox) in the Docker guest (ubuntu):

ImportError while loading conftest '/folder/python/tests/testcatalog/conftest.py'.
EINVAL: [Invalid argument]: samefile('/folder/python/tests/testcatalog/conftest.py', '/folder/python/tests/C:\\repos\\sdk\\python\\tests\\testcatalog\\conftest.py')

It seems the conftest.py is identifying both host and guest conftest.py files. In my opinion, it should only search for the guest.

Workaround:
If I copy the git folder into a new location in the Docker guest, it works fine.

The dependency list for tox:

deps =
    pytest
    pytest-html
    pytest-timeout
    future

Docker:
Windows host --> Ubuntu guest

question

Most helpful comment

when running pytest mounted across filesystems you'll need to clear .pyc files upon switching

All 3 comments

I also run outside tox, the issue remains.

pytest --version This is pytest version 4.6.2, imported from /usr/local/lib/python2.7/site-packages/pytest.pyc setuptools registered plugins: pytest-html-1.20.0 at /usr/local/lib/python2.7/site-packages/pytest_html/plugin.py pytest-metadata-1.8.0 at /usr/local/lib/python2.7/site-packages/pytest_metadata/plugin.py pytest-timeout-1.3.3 at /usr/local/lib/python2.7/site-packages/pytest_timeout.py pytest-calvin-0.1.0 at /usr/local/lib/python2.7/site-packages/pytest_calvin-0.1.0-py2.7.egg/pytest_calvin/plugin.pyc pytest-mock-1.10.4 at /usr/local/lib/python2.7/site-packages/pytest_mock-1.10.4-py2.7.egg/pytest_mock.py

pip list

  • atomicwrites 1.3.0
  • attrs 19.1.0
  • configparser 3.7.4
  • contextlib2 0.5.5
  • filelock 3.0.12
  • funcsigs 1.0.2
  • future 0.17.1
  • importlib-metadata 0.17
  • intel.tracecli 1.19232.0
  • mock 3.0.5
  • more-itertools 5.0.0
  • packaging 19.0
  • pathlib2 2.3.3
  • pip 19.1.1
  • pluggy 0.12.0
  • ply 3.11
  • psutil 5.6.2
  • py 1.8.0
  • pyasn1 0.4.5
  • pycryptodomex 3.8.2
  • pyparsing 2.4.0
  • pyserial 3.4
  • pysmi 0.3.4
  • pysnmp 4.4.9
  • pytest 4.6.2
  • pytest-calvin 0.1.0
  • pytest-html 1.20.0
  • pytest-metadata 1.8.0
  • pytest-mock 1.10.4
  • pytest-timeout 1.3.3
  • PyYAML 5.1
  • scandir 1.10.0
  • setuptools 39.0.1
  • six 1.12.0
  • toml 0.10.0
  • tox 3.12.1
  • virtualenv 16.6.0
  • wcwidth 0.1.7
  • wheel 0.33.4
  • zipp 0.5.1`

when running pytest mounted across filesystems you'll need to clear .pyc files upon switching

Thanks guys that was my issue!

Was this page helpful?
0 / 5 - 0 ratings