We found in a hard way that pytest is not playing along nicely with autoconf (or any tool which might use conftest* “file namespace” for their own purposes, as autoconf clobbers the conftest* files in the project’s root/build directory.
It’s true that autoconf is not universally loved, but OTOH even cpython is using it!
IMHO pytest ought to fix this, as otherwise it’s kind of “move fast and break things” attitude FOSS doesn’t appreciate, besides being pain in the neck to work around. I am interested to hear the list’s opinions on this.
Unfair? 20 years of breaking de facto standards don’t look good. Besides, autoconf was creating and compiling conftest.c files (and then doing rm -f conftest*) back in 1990 or so.
conftest.py files are well established in pytest since its inception, it is something really hard to change without breaking thousands of test suites downstream.
I suggest just moving the tests and the conftest.py files to a tests subdirectory, this seems to be a reasonable workaround.
nobody asked for conftest.py to be renamed. What was asked, and promptly dismissed (“not sensible for pytest to accommodate autoconf” (!)), was a possibility to have an alternative name for conftest.py, outside of the namespace clobbered by ./configure and libtool scripts.
We don’t even have tests/ - our doctests (and a number of specific tests run by pytest) are scattered across the repo. We tried to move conftest.py to src/, but it didn’t work for some reason.
Hmm. Well a conftest.py file is just a normal plugin, which pytest loads automatically.
Perhaps you can rename conftest.py to something else (say myfixtures.py), put it somewhere that is importable by pytest, then execute pytest -p myfixtures.
“somewhere important to pytest” is called conftest.py, and they appear to be unwilling to even consider a PR which would allow an alternative location.
it’s certainly more than just simply renaming the top-level conftest.py, say to foobar.py and passing foobar as the name of the pytest plugin to load at startup.
While your proposal works for calling pytest as python -m pytest, it doesn’t work for calling pytest directly. In the latter case plugins have to be blessed in, well, conftest.py, as far as I can see in the docs. These two different ways of calling pytest return slightly different results in our case.
So just do that then? Presumably you control exactly how your tests are run in CI and how you document your expected development process in your contributor guide.
Any project that prioritizes user experience would take care to construct a manifest of the files they create (or expect) and then delete only those. Frankly, issuing blanket rm -f commands with random file globs is irresponsible of autotools regardless of how long they have been doing it.