summaryrefslogtreecommitdiff
path: root/tests/test_django.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2014-05-18 12:16:51 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2014-05-18 14:18:49 +0200
commit80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa (patch)
tree8bdfc502d8a231fdc32a414eee61da628670a727 /tests/test_django.py
parent69894fce7977ea55f8cc3ad141840bab49330859 (diff)
downloadfactory-boy-80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa.tar
factory-boy-80eaa0c8711f2c3ca82eb7953db49c7c61bd9ffa.tar.gz
factory.django: Fix counter inheritance with abstract models.
Diffstat (limited to 'tests/test_django.py')
-rw-r--r--tests/test_django.py17
1 files changed, 15 insertions, 2 deletions
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)