-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fixture not found in test, but found in list of fixtures #3039
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
Comments
Khmm... anybody can produce some reaction on this ? |
Hi @EvgeniyMakhmudov, sorry for the lack of response. Currently you can't reference @RonnyPfannschmidt you know why is that feature in place? |
I've also ran into this issue when using |
bascially this works as intended - conftests are registred as plugins, but in actual execution they are ahadowed out so fixtures from conftests that get disabled for a directory tree are not availiable fixtures from plugin files would be availiable however |
|
A bit late to the party, but: I understand this works as intended, but if I try to grab fixtures in a niece/nephew At the very least:
|
I'm also facing similar issues.
Am I doing something wrong? |
Same issue: # customers/conftest.py
import pytest
from customers.models import Customer
@pytest.fixture
def customer() -> Customer:
return Customer.objects.create(
name="Rocicorp",
description="",
) # companies/conftest.py
import pytest
from customers.models import Customer
from companies.models import Company
pytest_plugins = ["customers.conftest"]
@pytest.fixture
def rocicorp(customer: Customer):
return Company.objects.create(
name="Rocicorp",
company_domain="rocicorp.com",
email="[email protected]",
customer=customer,
) # companies/tests.py
import pytest
@pytest.mark.django_db
def test_lol(rocicorp: Company):
company = Company.objects.first()
assert company.id == rocicorp.id
-------------------------- fixtures defined from companies.conftest ---------------------------
rocicorp -- companies/conftest.py:10
no docstring available
-------------------------- fixtures defined from customers.conftest ---------------------------
customer -- customers/conftest.py:7
no docstring available
==================================== no tests ran in 0.05s ====================================
@pytest.fixture
def rocicorp(customer: Customer):
E fixture 'customer' not found Any ideas? |
OK, solved like this: renamed # project root conftest.py
pytest_plugins = [
"customers.fixtures",
"companies.fixtures",
] |
Hi, is this the intended way to solve this issue every time? |
From reading this thread and my understanding, yes |
Ok, thanks |
I have a test project with this sctucture
My goal is use fixture from package_a for test in package_b. For this i used
pytest_plugins
Content of conftest's files:
Content of test (important test_b2):
Test failed with message fixture not found:
But if look in debug output we see that fixture_a1 founded:
Pip list:
What is going wrong? Fixture in list, why i can't use it? What i doing wrong? Is it bug or feature?
The text was updated successfully, but these errors were encountered: