2

Is there a decorator in Django that would allow to run the test function without applying fixtures?
Something like:

from django.test import TestCase

class TestSomething(TestCase):
    fixtures = ['test_fixture.json']

    def test_with_fixture(self):
        # test something with fixtures 

    @do_not_use_fixtures
    def test_without_fixtures(self): 
        # test something without fixtures
Ralf
  • 16,086
  • 4
  • 44
  • 68
ncopiy
  • 1,515
  • 14
  • 30

1 Answers1

2

Django's TestCase loads the fixtures once for the class for performance reasons. Therefore it isn't possible to run a test method without fixtures.

It might be possible with TransactionTestCase, but you'd have to dive into the Django internals to do this, so I wouldn't recommend it.

Alasdair
  • 298,606
  • 55
  • 578
  • 516