Reputation: 425
When I test using django.test.TransactionTestCase I have found that it uses the real database.
(django.test.TestCase works normally!)
I have confirmed this in my own project using the simple code:
class TestInventoryTransactions(TransactionTestCase):
def setUp(self):
print(Item.objects.all())
def test1(self):
pass
def test2(self):
pass
The output of this is
[...Bunch of items...]
[]
Showing that firstly that the real database is being used and not an empty test database. Secondly, it removes everything from the database after the first test.
I really don't think this is the expected behaviour and don't see why it would be happening.
Upvotes: 0
Views: 366
Reputation: 425
Using "manage.py test" does not have this problem. It only occurs when running the test file manually.
Upvotes: 1