diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2014-05-18 12:16:51 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2014-05-18 14:18:49 +0200 |
commit | 80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa (patch) | |
tree | 8bdfc502d8a231fdc32a414eee61da628670a727 /tests | |
parent | 69894fce7977ea55f8cc3ad141840bab49330859 (diff) | |
download | factory-boy-80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa.tar factory-boy-80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa.tar.gz |
factory.django: Fix counter inheritance with abstract models.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/djapp/models.py | 11 | ||||
-rw-r--r-- | tests/test_django.py | 17 |
2 files changed, 25 insertions, 3 deletions
diff --git a/tests/djapp/models.py b/tests/djapp/models.py index a65b50a..9b21181 100644 --- a/tests/djapp/models.py +++ b/tests/djapp/models.py @@ -55,6 +55,15 @@ class ConcreteSon(AbstractBase): pass +class AbstractSon(AbstractBase): + class Meta: + abstract = True + + +class ConcreteGrandSon(AbstractSon): + pass + + class StandardSon(StandardModel): pass @@ -77,4 +86,4 @@ else: class WithSignals(models.Model): - foo = models.CharField(max_length=20)
\ No newline at end of file + foo = models.CharField(max_length=20) diff --git a/tests/test_django.py b/tests/test_django.py index 29453e6..37bf7a5 100644 --- a/tests/test_django.py +++ b/tests/test_django.py @@ -130,6 +130,14 @@ class ConcreteSonFactory(AbstractBaseFactory): FACTORY_FOR = models.ConcreteSon +class AbstractSonFactory(AbstractBaseFactory): + FACTORY_FOR = models.AbstractSon + + +class ConcreteGrandSonFactory(AbstractBaseFactory): + FACTORY_FOR = models.ConcreteGrandSon + + class WithFileFactory(factory.django.DjangoModelFactory): FACTORY_FOR = models.WithFile @@ -307,8 +315,13 @@ class DjangoNonIntegerPkTestCase(django_test.TestCase): @unittest.skipIf(django is None, "Django not installed.") class DjangoAbstractBaseSequenceTestCase(django_test.TestCase): def test_auto_sequence(self): - with factory.debug(): - obj = ConcreteSonFactory() + """The sequence of the concrete son of an abstract model should be autonomous.""" + obj = ConcreteSonFactory() + self.assertEqual(1, obj.pk) + + def test_auto_sequence(self): + """The sequence of the concrete grandson of an abstract model should be autonomous.""" + obj = ConcreteGrandSonFactory() self.assertEqual(1, obj.pk) |