pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.97k stars 2.66k forks source link

Pytest won't find fixtures after updating to MacOS Ventura (13.0.1, x86) #10528

Closed piermarcob closed 1 year ago

piermarcob commented 1 year ago
The-Compiler commented 1 year ago

Can you please show the full output of your pytest run? Also, in your Dropbox, I can only find a debug log, not a minimal example.

piermarcob commented 1 year ago

Hi Florian, thanks for the quick response and sorry if i missed posting all the needed information.

Here is the output of running pytest -xvrP. Please note that this process works on other machines running MacOS (same version of mine or older) and Linux (ubuntu server) test.log

Thanks again for putting effort in looking into this.

The-Compiler commented 1 year ago

And where/how exactly is e.g. remove_all_communities defined?

piermarcob commented 1 year ago

It is defined in contest.py, which is correctly loaded on other platforms.

The-Compiler commented 1 year ago

Sorry for the delay, I dropped the ball a bit here.

So I see a /Users/piermarcobarbe/git/vylto-infrastructure/backend/tests/conftest.py being loaded in your logs. However, the test seems to be at /Users/piermarcobarbe/git/vylto-infrastructure/test_analytics.py. Where exactly is the conftest.py (not contest.py I hope?) which isn't getting loaded.

Can you perhaps share your repository or a minimal example project exhibiting the same problem? I'm afraid it's almost impossible to debug this like this.

piermarcob commented 1 year ago

Hi Florian,

Sorry for the typo (contest.py -> conftest.py), our project file was and is named correctly.

Hmm, thanks for letting me notice that a file named test_analytics.py was found in our project root directory. That is weird as we collect tests in a specific directory and finding a test file outside of it is weird to read.

I am sorry to tell you that I had to wipe my Mac since tests were not running anymore and I couln't afford any more time on this, but i can confirm that there was actually a file named test_analytics.py outside test directory and I think this was causing pytest to crash / not to find fixtures.

So, just to be clear, the structure was:

- vylto-infrastructure/
  - test_analytics.py

as correctly reported by the pytest log.

Certainly this was a mistake on my side, do you think pytest can detect this kind of situations and maybe warn the user about it?

Thanks again for your time.

The-Compiler commented 1 year ago

Well, if you have a test in vylto-infrastructure/test_analytics.py, but your fixture defined in vylto-infrastructure/backend/tests/conftest.py, that's not going to work - a conftest.py is only valid for the directory it's in, or any subdirectories.

I don't see what pytest could detect or warn about - this is normal and valid usage of pytest.