@pytest.fixture(scope='function')
@pytest.mark.django_db()
def authenticated_user_object(authenticated_user_data):
user = get_user_model().objects.create_user(
**authenticated_user_data
)
return user
After saving the user information in the DB as above with pytest, I tried to run the test by setting the scope to a level higher than the 'function' level to run several tests. However, I received a log message that DB access was not allowed, and while I was looking into it in detail, I was wondering why DB access was denied at the function level.
- Specifically, what is the reason for making DB access impossible in scopes beyond function?
- Are there other ways to access the DB?