summaryrefslogtreecommitdiff
path: root/factory/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 /factory/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 'factory/utils.py')
-rw-r--r--factory/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/factory/utils.py b/factory/utils.py
index c592da4..e7cdf5f 100644
--- a/factory/utils.py
+++ b/factory/utils.py
@@ -81,3 +81,15 @@ def multi_extract_dict(prefixes, kwargs, pop=True, exclude=()):
['%s%s%s' % (prefix, ATTR_SPLITTER, key) for key in extracted])
return results
+
+
+def import_object(module_name, attribute_name):
+ """Import an object from its absolute path.
+
+ Example:
+ >>> import_object('datetime', 'datetime')
+ <type 'datetime.datetime'>
+ """
+ module = __import__(module_name, {}, {}, [attribute_name], 0)
+ return getattr(module, attribute_name)
+