I have this factory as ficture:
@pytest.fixture
def user_factory(db):
def create_app_user(
username: str,
password: str = None,
first_name: str = "firstname",
last_name: str = "lastname",
email: str = "user@g.com",
is_staff: str = False,
is_superuser: str = False,
is_active: str = True
):
user_f = User.objects.create_user(
username = username,
password = password,
first_name = first_name,
last_name = last_name,
email = email,
is_staff = is_staff,
is_superuser = is_superuser,
is_active = is_active
)
return user_f
return create_app_user
@pytest.fixture
def new_user(db, user_factory):
return user_factory("myusername", "mypassword", "myfirstname")
I tried to use the factory to run this test which is located in test_name.py file:
def create_new_user(new_user):
print(new_user.first_name)
assert new_user.first_name == "myfirstname"
However, the test didn't run and no error message was produced. I have the factory in my root inside the conftest.py file as mentioned in the documentation. I also have this settings in my pytest.ini file:
python_files = tests.py test_*.py *_test.py
What could have happened please?