Pytest IndexError: tuple index out of range

36 Views Asked by At

Currently I'm trying to configure my django rest API with pytest. When I tried to use models with @pytest.mark.django_db I get an error mentioning that tuple index out of range even though I do not refer any tuples in the test case. But everything works fine when I do not do any database queries or not use @pytest.mark.django_db

import pytest
from report_tenant.models import VisualModelTableColumn


@pytest.mark.django_db
def test_visual_model_table_column_table():
    col = Model.objects.create(key_1=1, key_2=1, key_5=1, key_3=1, key_4=1)
    assert True == True

1

There are 1 best solutions below

0
Shakya Peiris On

I named my conftest as confest. Renaming it got my job done.

Conclusion: If someone is having any issue with the DB connectivity when using pytest, just checking the conftest would most probably get you job done.