summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2016-03-12 12:45:34 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2016-03-12 12:46:35 +0100
commitdc1de7297b9b508afad9386285aebd57ac3f11f2 (patch)
tree8ddf1caa8807393734a1bd4c3cc2c65b2c1f14e5
parentdc101609604a1377276312811cfaf98d7772576b (diff)
downloadfactory-boy-dc1de7297b9b508afad9386285aebd57ac3f11f2.tar
factory-boy-dc1de7297b9b508afad9386285aebd57ac3f11f2.tar.gz
django: Clarify behavior around ``abstract=True``
See issue #280.
-rw-r--r--tests/test_django.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_django.py b/tests/test_django.py
index 103df91..08349b9 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -362,6 +362,22 @@ class DjangoAbstractBaseSequenceTestCase(django_test.TestCase):
obj = ConcreteGrandSonFactory()
self.assertEqual(1, obj.pk)
+ def test_optional_abstract(self):
+ """Users need not describe the factory for an abstract model as abstract."""
+ class AbstractBaseFactory(factory.django.DjangoModelFactory):
+ class Meta:
+ model = models.AbstractBase
+
+ foo = factory.Sequence(lambda n: "foo%d" % n)
+
+ class ConcreteSonFactory(AbstractBaseFactory):
+ class Meta:
+ model = models.ConcreteSon
+
+ obj = ConcreteSonFactory()
+ self.assertEqual(1, obj.pk)
+ self.assertEqual("foo0", obj.foo)
+
@unittest.skipIf(django is None, "Django not installed.")
class DjangoRelatedFieldTestCase(django_test.TestCase):