Why records are not being inserted into postgresql database in pytest-django?

I tried to use postgres database with pytest-django and I've encountered a problem. I have a fixture named populate_db which creates some records in the database. To check if pytest actually creates records, I put a 60-seconds sleep after creating the model objects and checked the panel admin but none of the created objects were present there. I think the pytest can't connect to my database and doesn't create any records in the database. Below are the functions that I have in my conftest.py file and I have another test file which tries to retrieve a database record from the API.

Here is my code for the populate_db fixture:

@pytest.fixture(autouse=True)
def populate_db():
    sport = Vertical.objects.create(name='sport')
    bazar = Vertical.objects.create(name='bazar')
    
    time.sleep(60)
    yield
Back to Top