summaryrefslogtreecommitdiff
path: root/tests/test_django.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2015-03-27 16:27:05 +0100
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2015-03-27 16:27:05 +0100
commitbdc1b815cfdf3028379c6c3f18c9c47ee8298a70 (patch)
treea15ef5f62f091aa3a06d41a9a7bd40129f921aae /tests/test_django.py
parent03ca4ecebc914f2e120e902b8fcbe2b526460ee6 (diff)
downloadfactory-boy-bdc1b815cfdf3028379c6c3f18c9c47ee8298a70.tar
factory-boy-bdc1b815cfdf3028379c6c3f18c9c47ee8298a70.tar.gz
Respect default manager in DjangoModelFactory (Closes #192).
The previous version tries to use ``cls._default_manager`` all the time, which breaks with ``manager.using(db_name)``.
Diffstat (limited to 'tests/test_django.py')
-rw-r--r--tests/test_django.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_django.py b/tests/test_django.py
index 2744032..9ac8f5c 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -157,6 +157,13 @@ if django is not None:
model = models.WithSignals
+ class WithCustomManagerFactory(factory.django.DjangoModelFactory):
+ class Meta:
+ model = models.WithCustomManager
+
+ foo = factory.Sequence(lambda n: "foo%d" % n)
+
+
@unittest.skipIf(django is None, "Django not installed.")
class ModelTests(django_test.TestCase):
def test_unset_model(self):
@@ -706,5 +713,10 @@ class PreventSignalsTestCase(unittest.TestCase):
self.assertSignalsReactivated()
+class DjangoCustomManagerTestCase(django_test.TestCase):
+
+ def test_extra_args(self):
+ model = WithCustomManagerFactory(arg='foo')
+
if __name__ == '__main__': # pragma: no cover
unittest.main()