Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

factory passing

  • Loading branch information...
commit 41b674f0a6a0a9d9af60bc00c520006ba3198f6c 1 parent c9eddf6
Mikko Hellsing authored
View
5 CHANGES.rst
@@ -1,6 +1,11 @@
Changelog
=========
+0.4.2
+-----
+* Make ModelMockup take a factory instance as keyword argument for more
+ flexibility
+
0.4.1
-----
* Just a rename of Mockup to ModelMockup
View
11 mockups/base.py
@@ -110,14 +110,19 @@ def __init__(self, model, constraints=None, follow_fk=None,
``ManyToManyField``. Default is ``False`` which disables the
generation of new related instances. The value of ``follow_m2m``
will be ignored if this parameter is set.
+
+ ``factory``: A Factory *instance*, overriding the one defined in the
+ ModelMockup class.
'''
self.model = model
self.constraints = constraints or []
- # create a factory instance
+ # instantiate the factory class
if factory is not None:
- self.factory = factory
- self._factory = self.factory()
+ self.factory = factory.__class__
+ self._factory = factory
+ else:
+ self._factory = self.factory()
if follow_fk is not None:
self.follow_fk = follow_fk
View
1  mockups/generators.py
@@ -493,7 +493,6 @@ def generate(self):
#
# Field coupled generators
#
-# TODO make sure in a better way that generators use empty_p = 0
class FieldGenerator(Generator):
def __init__(self, field, **kwargs):
empty_p = kwargs.pop('empty_p', None)
View
2  setup.py
@@ -32,7 +32,7 @@ def split(self, *args, **kw):
setup(
name = 'django-mockups',
- version = '0.4.1',
+ version = '0.4.2',
url = 'https://github.com/sorl/django-mockups',
license = 'BSD',
description = 'Provides tools to auto generate content.',
Please sign in to comment.
Something went wrong with that request. Please try again.