zsoldosp / django-currentuser

Conveniently store reference to request user on thread/db level.
BSD 3-Clause "New" or "Revised" License
157 stars 40 forks source link

Key (modified_by_id)=(1) is not present in table "account_customuser" when running unit test #47

Closed paulexconde closed 2 years ago

bethlakshmi commented 3 years ago

I'm having the same problem

zvyn commented 2 years ago

A workaround is to set the user to None explicitly when setting up the test. For pytest this works for me:

@pytest.fixture(autouse=True)
def unset_user():
    from django_currentuser.middleware import _set_current_user

    _set_current_user()
paulexconde commented 2 years ago

A workaround is to set the user to None explicitly when setting up the test. For pytest this works for me:

@pytest.fixture(autouse=True)
def unset_user():
    from django_currentuser.middleware import _set_current_user

    _set_current_user()

@zvyn , Thanks 👍