xflr6 / graphviz

Simple Python interface for Graphviz
https://graphviz.readthedocs.io
MIT License
1.59k stars 209 forks source link

Non-unique module names cause test failures with pytest #221

Closed alerque closed 3 months ago

alerque commented 3 months ago

Using pytest to check the v0.20.3 release while building for Arch Linux turns up the folowing issue:

============================= test session starts ==============================
platform linux -- Python 3.11.8, pytest-8.1.1, pluggy-1.4.0
rootdir: /build/python-graphviz/src/graphviz-0.20.3
configfile: setup.cfg
plugins: mock-3.12.0
collected 329 items / 1 error

==================================== ERRORS ====================================
______________________ ERROR collecting tests/conftest.py ______________________
import file mismatch:
imported module 'conftest' has this __file__ attribute:
  /build/python-graphviz/src/graphviz-0.20.3/tests/backend/conftest.py
which is not the same as the test file we want to collect:
  /build/python-graphviz/src/graphviz-0.20.3/tests/conftest.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.18s ===============================

It looks like the module names should be fixed to be unique so this isn't an issue. It can probably be avoided by moving the build artifacts to a different location than the test sources, but this shouldn't be an issue in the first place.

I originally opened this issue on the wrong repository and a commenter on that issue suggested it is valid to have a conftest.py. I don't know how it's supposed to work and they are probably right, but some aspect of namespacing / isolation / test configuration is off here.

xflr6 commented 3 months ago

Duplicate of #219.

See https://graphviz.readthedocs.io/en/latest/changelog.html#version-0-20-2 and https://github.com/pytest-dev/pytest/issues/12123

xflr6 commented 3 months ago

some aspect of namespacing / isolation / test configuration is off here.

Not sure about that, so far this looks like a pytest regression.