Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctest_namespace fixture is not used depending on whether other tests run #10775

Open
3 of 4 tasks
kratsg opened this issue Feb 28, 2023 · 2 comments
Open
3 of 4 tasks
Labels
topic: fixtures anything involving fixtures directly or indirectly type: question general question, might be closed after 2 weeks of inactivity

Comments

@kratsg
Copy link

kratsg commented Feb 28, 2023

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

See #2379. Take the example there, which is already described as not functioning, but then add a new test file under tests called tests/test_helloworld.py and make a simple test like

def test_true():
  assert True

So the structure looks like

.
├── src
│   └── testpackage
│       └── __init__.py
└── tests
    └── conftest.py
    └── test_helloworld.py

Then the doctest_namespace fixture is picked up in the doctests and the issue is "fixed". This seems like somewhat inconsistent behavior when it comes to discovery and makes it really hard to debug. Is this expected behavior?

OS Details

$ pytest --version
pytest 7.2.1
$ uname -a
Darwin ghost.lan 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64
@RonnyPfannschmidt
Copy link
Member

The conftest only applies within its folder, the src folder is not within its folder

@kratsg
Copy link
Author

kratsg commented Feb 28, 2023

The conftest only applies within its folder, the src folder is not within its folder

This is what is described on the other thread. But having a test under tests/ has src/__init__.py doctest passing because hello gets defined, even though it's in the conftest.py under tests/ only. I understand your explanation, but that's not the behavior I'm seeing in pytest.

@Zac-HD Zac-HD added type: question general question, might be closed after 2 weeks of inactivity topic: fixtures anything involving fixtures directly or indirectly labels Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants