summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 02:16:42 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-09 02:16:42 +0200
commita31e87f19b7c193b980d0f54971c12a60e8c7263 (patch)
tree2ccf86db6921f19363176db6de561a452a212aea /tests/test_utils.py
parente0e628ec54b8a4d7f41f86f9f535d791a437b13c (diff)
downloadfactory-boy-a31e87f19b7c193b980d0f54971c12a60e8c7263.tar
factory-boy-a31e87f19b7c193b980d0f54971c12a60e8c7263.tar.gz
Introduce 'CircularSubFactory.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index f30c0e3..dbc357b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -212,3 +212,18 @@ class MultiExtractDictTestCase(unittest.TestCase):
self.assertNotIn('foo__foo__bar', d)
self.assertNotIn('bar__foo', d)
self.assertNotIn('bar__bar__baz', d)
+
+class ImportObjectTestCase(unittest.TestCase):
+ def test_datetime(self):
+ imported = utils.import_object('datetime', 'date')
+ import datetime
+ d = datetime.date
+ self.assertEqual(d, imported)
+
+ def test_unknown_attribute(self):
+ self.assertRaises(AttributeError, utils.import_object,
+ 'datetime', 'foo')
+
+ def test_invalid_module(self):
+ self.assertRaises(ImportError, utils.import_object,
+ 'this-is-an-invalid-module', '__name__')