﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31299	DB not flushed between TestCases	Lokesh Gurram	ChillarAnand	"Consider the case where I have two fixtures and two different TestCase classes that use them.

**fixture1.json**

{{{
[
{
    ""model"": ""app1.user"",
    ""pk"": 1,
    ""fields"": {
        ""password"": """",
        ""last_login"": null,
        ""is_superuser"": false,
        ""username"": ""tesuser1"",
        ""first_name"": """",
        ""last_name"": """",
        ""is_staff"": false,
        ""is_active"": true,
        ""date_joined"": ""2020-02-21T12:59:17.302Z"",
        ""email"": null,
        ""groups"": [],
        ""user_permissions"": []
    }
}
]
}}}

**fixture2.json**

{{{
[
{
    ""model"": ""app1.user"",
    ""pk"": 2,
    ""fields"": {
        ""password"": """",
        ""last_login"": null,
        ""is_superuser"": false,
        ""username"": ""testuser2"",
        ""first_name"": """",
        ""last_name"": """",
        ""is_staff"": false,
        ""is_active"": true,
        ""date_joined"": ""2020-02-21T12:59:17.302Z"",
        ""email"": null,
        ""groups"": [],
        ""user_permissions"": []
    }
}
]
}}}


**Here are my test cases**
{{{
class Test1(TestCase):
    fixtures = ['fixture1.json']

    @classmethod
    def tearDownClass(cls):
        super(TestCase, cls).tearDownClass()

    def test_demo(self):
        u = User.objects.get(username='testuser1')
        #some testing

class Test2(TestCase):
    fixtures = ['fixture2.json']

    @classmethod
    def tearDownClass(cls):
        super(TestCase, cls).tearDownClass()

    def test_demo2(self):
        try:
            u = User.objects.get(username='testuser1')
            print(""Found him"")
            #Some testing
        except:
            pass
}}}

I wouldn't expect to find testuser1 in my second test case as the fixtures for it doesn't have that particular user. 

**From django  documentation:**
At the start of each test, before setUp() is run, Django will flush the database, returning the database to the state it was in directly after migrate was called."	Bug	closed	Testing framework	2.2	Normal	invalid	TestCases, Fixtures		Unreviewed	0	0	0	0	0	0
