Ticket #5624: doctest-fixtures.diff
File doctest-fixtures.diff, 2.9 KB (added by , 17 years ago) |
---|
-
django/test/testcases.py
47 47 # side effects on other tests. 48 48 transaction.rollback_unless_managed() 49 49 50 def run(self, test, compileflags=None, out=None, clear_globs=True): 51 call_command('flush', verbosity=0, interactive=False) 52 if '__fixtures__' in test.globs: 53 # We have to use this slightly awkward syntax due to the fact 54 # that we're using *args and **kwargs together. 55 call_command('loaddata', *test.globs['__fixtures__'], **{'verbosity': 0}) 56 return doctest.DocTestRunner.run(self, test, compileflags, out, clear_globs) 57 50 58 class TestCase(unittest.TestCase): 51 59 def _pre_setup(self): 52 60 """Performs any pre-test setup. This includes: -
tests/regressiontests/doctest_fixtures/fixtures/doctest_fixture.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <django-objects version="1.0"> 3 <object pk="1" model="doctest_fixtures.band"> 4 <field type="CharField" name="name">The Doors</field> 5 </object> 6 </django-objects> -
tests/regressiontests/doctest_fixtures/models.py
1 """ 2 This object should have been loaded from the doctest_fixture.xml fixture. 3 4 >>> Band.objects.get(pk=1) 5 <Band: The Doors> 6 """ 7 8 from django.db import models 9 10 class Band(models.Model): 11 """ 12 This object should have been loaded from the doctest_fixture.xml fixture. 13 14 >>> Band.objects.get(pk=1) 15 <Band: The Doors> 16 """ 17 name = models.CharField(max_length=100) 18 19 def __unicode__(self): 20 """ 21 This object should have been loaded from the doctest_fixture.xml fixture. 22 23 >>> Band.objects.get(pk=1) 24 <Band: The Doors> 25 """ 26 return self.name 27 28 def test(self): 29 """ 30 This object should have been loaded from the doctest_fixture.xml fixture. 31 32 >>> Band.objects.get(pk=1) 33 <Band: The Doors> 34 """ 35 pass 36 37 __fixtures__ = ['doctest_fixture.xml'] 38 39 __test__ = {'API_TESTS': """ 40 This object should have been loaded from the doctest_fixture.xml fixture. 41 42 >>> Band.objects.get(pk=1) 43 <Band: The Doors> 44 """}