aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst12
-rw-r--r--docs/examples.rst4
-rw-r--r--docs/introduction.rst24
-rw-r--r--docs/orms.rst18
-rw-r--r--docs/recipes.rst30
-rw-r--r--docs/reference.rst106
-rw-r--r--factory/alchemy.py6
-rw-r--r--factory/base.py76
-rw-r--r--factory/containers.py14
-rw-r--r--factory/declarations.py4
-rw-r--r--factory/django.py28
-rw-r--r--factory/helpers.py2
-rw-r--r--factory/mogo.py8
-rw-r--r--factory/mongoengine.py8
-rw-r--r--tests/cyclic/bar.py2
-rw-r--r--tests/cyclic/foo.py2
-rw-r--r--tests/test_alchemy.py4
-rw-r--r--tests/test_base.py56
-rw-r--r--tests/test_containers.py2
-rw-r--r--tests/test_deprecation.py2
-rw-r--r--tests/test_django.py40
-rw-r--r--tests/test_mongoengine.py4
-rw-r--r--tests/test_using.py246
23 files changed, 349 insertions, 349 deletions
diff --git a/README.rst b/README.rst
index 787d754..b4ba689 100644
--- a/README.rst
+++ b/README.rst
@@ -95,7 +95,7 @@ Defining factories
""""""""""""""""""
Factories declare a set of attributes used to instantiate an object.
-The class of the object must be defined in the ``target`` field of a ``class Meta:`` attribute:
+The class of the object must be defined in the ``model`` field of a ``class Meta:`` attribute:
.. code-block:: python
@@ -104,7 +104,7 @@ The class of the object must be defined in the ``target`` field of a ``class Met
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
first_name = 'John'
last_name = 'Doe'
@@ -113,7 +113,7 @@ The class of the object must be defined in the ``target`` field of a ``class Met
# Another, different, factory for the same object
class AdminFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
first_name = 'Admin'
last_name = 'User'
@@ -168,7 +168,7 @@ These "lazy" attributes can be added as follows:
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
first_name = 'Joe'
last_name = 'Blow'
@@ -189,7 +189,7 @@ Unique values in a specific format (for example, e-mail addresses) can be genera
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
email = factory.Sequence(lambda n: 'person{0}@example.com'.format(n))
@@ -209,7 +209,7 @@ This is handled by the ``SubFactory`` helper:
class PostFactory(factory.Factory):
class Meta:
- target = models.Post
+ model = models.Post
author = factory.SubFactory(UserFactory)
diff --git a/docs/examples.rst b/docs/examples.rst
index 52a5ef6..a57080e 100644
--- a/docs/examples.rst
+++ b/docs/examples.rst
@@ -57,7 +57,7 @@ And now, we'll define the related factories:
class AccountFactory(factory.Factory):
class Meta:
- target = objects.Account
+ model = objects.Account
username = factory.Sequence(lambda n: 'john%s' % n)
email = factory.LazyAttribute(lambda o: '%s@example.org' % o.username)
@@ -65,7 +65,7 @@ And now, we'll define the related factories:
class ProfileFactory(factory.Factory):
class Meta:
- target = objects.Profile
+ model = objects.Profile
account = factory.SubFactory(AccountFactory)
gender = factory.Iterator([objects.Profile.GENDER_MALE, objects.Profile.GENDER_FEMALE])
diff --git a/docs/introduction.rst b/docs/introduction.rst
index 6ea6b5e..5e3b4d8 100644
--- a/docs/introduction.rst
+++ b/docs/introduction.rst
@@ -18,11 +18,11 @@ Basic usage
-----------
-Factories declare a set of attributes used to instantiate an object, whose class is defined in the ``class Meta``'s ``target`` attribute:
+Factories declare a set of attributes used to instantiate an object, whose class is defined in the ``class Meta``'s ``model`` attribute:
- Subclass ``factory.Factory`` (or a more suitable subclass)
- Add a ``class Meta:`` block
-- Set its ``target`` attribute to the target class
+- Set its ``model`` attribute to the target class
- Add defaults for keyword args to pass to the associated class' ``__init__`` method
@@ -33,7 +33,7 @@ Factories declare a set of attributes used to instantiate an object, whose class
class UserFactory(factory.Factory):
class Meta:
- target = base.User
+ model = base.User
firstname = "John"
lastname = "Doe"
@@ -59,7 +59,7 @@ A given class may be associated to many :class:`~factory.Factory` subclasses:
class EnglishUserFactory(factory.Factory):
class Meta:
- target = base.User
+ model = base.User
firstname = "John"
lastname = "Doe"
@@ -68,7 +68,7 @@ A given class may be associated to many :class:`~factory.Factory` subclasses:
class FrenchUserFactory(factory.Factory):
class Meta:
- target = base.User
+ model = base.User
firstname = "Jean"
lastname = "Dupont"
@@ -93,7 +93,7 @@ This is achieved with the :class:`~factory.Sequence` declaration:
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
username = factory.Sequence(lambda n: 'user%d' % n)
@@ -110,7 +110,7 @@ This is achieved with the :class:`~factory.Sequence` declaration:
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
@factory.sequence
def username(n):
@@ -128,7 +128,7 @@ taking the object being built and returning the value for the field:
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
username = factory.Sequence(lambda n: 'user%d' % n)
email = factory.LazyAttribute(lambda obj: '%s@example.com' % obj.username)
@@ -154,7 +154,7 @@ taking the object being built and returning the value for the field:
class UserFactory(factory.Factory):
class Meta:
- target = models.User
+ model = models.User
username = factory.Sequence(lambda n: 'user%d' % n)
@@ -177,7 +177,7 @@ and update them with its own declarations:
class UserFactory(factory.Factory):
class Meta:
- target = base.User
+ model = base.User
firstname = "John"
lastname = "Doe"
@@ -224,7 +224,7 @@ This is handled by the :data:`~factory.FactoryOptions.arg_parameters` attribute:
class MyFactory(factory.Factory):
class Meta:
- target = MyClass
+ model = MyClass
arg_parameters = ('x', 'y')
x = 1
@@ -262,7 +262,7 @@ Calling a :class:`~factory.Factory` subclass will provide an object through the
class MyFactory(factory.Factory):
class Meta:
- target = MyClass
+ model = MyClass
.. code-block:: pycon
diff --git a/docs/orms.rst b/docs/orms.rst
index 5ef8568..d3d98c9 100644
--- a/docs/orms.rst
+++ b/docs/orms.rst
@@ -32,7 +32,7 @@ All factories for a Django :class:`~django.db.models.Model` should use the
This class provides the following features:
- * The :attr:`~factory.FactoryOption.target` attribute also supports the ``'app.Model'``
+ * The :attr:`~factory.FactoryOptions.model` attribute also supports the ``'app.Model'``
syntax
* :func:`~factory.Factory.create()` uses :meth:`Model.objects.create() <django.db.models.query.QuerySet.create>`
* :func:`~factory.Factory._setup_next_sequence()` selects the next unused primary key value
@@ -55,7 +55,7 @@ All factories for a Django :class:`~django.db.models.Model` should use the
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = 'myapp.User' # Equivalent to ``target = myapp.models.User``
+ model = 'myapp.User' # Equivalent to ``model = myapp.models.User``
django_get_or_create = ('username',)
username = 'john'
@@ -87,12 +87,12 @@ All factories for a Django :class:`~django.db.models.Model` should use the
class MyAbstractModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.MyAbstractModel
+ model = models.MyAbstractModel
abstract = True
class MyConcreteModelFactory(MyAbstractModelFactory):
class Meta:
- target = models.MyConcreteModel
+ model = models.MyConcreteModel
Otherwise, factory_boy will try to get the 'next PK' counter from the abstract model.
@@ -121,7 +121,7 @@ Extra fields
class MyFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.MyModel
+ model = models.MyModel
the_file = factory.django.FileField(filename='the_file.dat')
@@ -159,7 +159,7 @@ Extra fields
class MyFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.MyModel
+ model = models.MyModel
the_image = factory.django.ImageField(color='blue')
@@ -199,7 +199,7 @@ To work around this problem, use the :meth:`mute_signals()` decorator/context ma
@factory.django.mute_signals(signals.pre_save, signals.post_save)
class FooFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.Foo
+ model = models.Foo
# ...
@@ -252,7 +252,7 @@ factory_boy supports `MongoEngine`_-style models, through the :class:`MongoEngin
* :func:`~factory.Factory.create()` builds an instance through ``__init__`` then
saves it.
- .. note:: If the :attr:`associated class <factory.FactoryOptions.target>` is a :class:`mongoengine.EmbeddedDocument`,
+ .. note:: If the :attr:`associated class <factory.FactoryOptions.model` is a :class:`mongoengine.EmbeddedDocument`,
the :meth:`~MongoEngineFactory.create` function won't "save" it, since this wouldn't make sense.
This feature makes it possible to use :class:`~factory.SubFactory` to create embedded document.
@@ -314,7 +314,7 @@ A (very) simple exemple:
class UserFactory(SQLAlchemyModelFactory):
class Meta:
- target = User
+ model = User
sqlalchemy_session = session # the SQLAlchemy session object
id = factory.Sequence(lambda n: n)
diff --git a/docs/recipes.rst b/docs/recipes.rst
index 917bc3c..72dacef 100644
--- a/docs/recipes.rst
+++ b/docs/recipes.rst
@@ -27,7 +27,7 @@ use the :class:`~factory.SubFactory` declaration:
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
first_name = factory.Sequence(lambda n: "Agent %03d" % n)
group = factory.SubFactory(GroupFactory)
@@ -55,7 +55,7 @@ use a :class:`~factory.RelatedFactory` declaration:
# factories.py
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
log = factory.RelatedFactory(UserLogFactory, 'user', action=models.UserLog.ACTION_CREATE)
@@ -78,7 +78,7 @@ factory_boy allows to define attributes of such profiles dynamically when creati
class ProfileFactory(factory.django.DjangoModelFactory):
class Meta:
- target = my_models.Profile
+ model = my_models.Profile
title = 'Dr'
# We pass in profile=None to prevent UserFactory from creating another profile
@@ -87,7 +87,7 @@ factory_boy allows to define attributes of such profiles dynamically when creati
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = auth_models.User
+ model = auth_models.User
username = factory.Sequence(lambda n: "user_%d" % n)
@@ -150,13 +150,13 @@ hook:
# factories.py
class GroupFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.Group
+ model = models.Group
name = factory.Sequence(lambda n: "Group #%s" % n)
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
name = "John Doe"
@@ -207,19 +207,19 @@ If more links are needed, simply add more :class:`RelatedFactory` declarations:
# factories.py
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
name = "John Doe"
class GroupFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.Group
+ model = models.Group
name = "Admins"
class GroupLevelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.GroupLevel
+ model = models.GroupLevel
user = factory.SubFactory(UserFactory)
group = factory.SubFactory(GroupFactory)
@@ -283,14 +283,14 @@ Here, we want:
# factories.py
class CountryFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.Country
+ model = models.Country
name = factory.Iterator(["France", "Italy", "Spain"])
lang = factory.Iterator(['fr', 'it', 'es'])
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
name = "John"
lang = factory.SelfAttribute('country.lang')
@@ -298,7 +298,7 @@ Here, we want:
class CompanyFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.Company
+ model = models.Company
name = "ACME, Inc."
country = factory.SubFactory(CountryFactory)
@@ -315,15 +315,15 @@ default :meth:`Model.objects.create() <django.db.models.query.QuerySet.create>`
class UserFactory(factory.DjangoModelFactory):
class Meta:
- target = UserenaSignup
+ model = UserenaSignup
username = "l7d8s"
email = "my_name@example.com"
password = "my_password"
@classmethod
- def _create(cls, target_class, *args, **kwargs):
+ def _create(cls, model_class, *args, **kwargs):
"""Override the default ``_create`` with our custom call."""
- manager = cls._get_manager(target_class)
+ manager = cls._get_manager(model_class)
# The default would use ``manager.create(*args, **kwargs)``
return manager.create_user(*args, **kwargs)
diff --git a/docs/reference.rst b/docs/reference.rst
index f19b44e..d616d1c 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -23,10 +23,10 @@ The :class:`Factory` class
class MyFactory(factory.Factory):
class Meta:
- target = MyObject
+ model = MyObject
abstract = False
- .. attribute:: target
+ .. attribute:: model
This optional attribute describes the class of objects to generate.
@@ -40,10 +40,10 @@ The :class:`Factory` class
be used to generate objects, but instead provides some extra defaults.
It will be automatically set to ``True`` if neither the :class:`Factory`
- subclass nor its parents define the :attr:`~FactoryOptions.target` attribute.
+ subclass nor its parents define the :attr:`~FactoryOptions.model` attribute.
.. warning:: This flag is reset to ``False`` When a :class:`Factory` subclasses
- another one if a :attr:`~FactoryOptions.target` is set.
+ another one if a :attr:`~FactoryOptions.model` is set.
.. versionadded:: 2.4.0
@@ -57,7 +57,7 @@ The :class:`Factory` class
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
arg_parameters = ('login', 'email')
login = 'john'
@@ -76,7 +76,7 @@ The :class:`Factory` class
While writing a :class:`Factory` for some object, it may be useful to
have general fields helping defining others, but that should not be
- passed to the target class; for instance, a field named 'now' that would
+ passed to the model class; for instance, a field named 'now' that would
hold a reference time used by other objects.
Factory fields whose name are listed in :attr:`hidden_args` will
@@ -87,7 +87,7 @@ The :class:`Factory` class
class OrderFactory(factory.Factory):
class Meta:
- target = Order
+ model = Order
hidden_args = ('now',)
now = factory.LazyAttribute(lambda o: datetime.datetime.utcnow())
@@ -115,7 +115,7 @@ The :class:`Factory` class
.. attribute:: FACTORY_FOR
.. deprecated:: 2.4.0
- See :attr:`FactoryOptions.target`.
+ See :attr:`FactoryOptions.model`.
.. attribute:: ABSTRACT_FACTORY
@@ -258,19 +258,19 @@ The :class:`Factory` class
Subclasses may fetch the next free ID from the database, for instance.
- .. classmethod:: _build(cls, target_class, *args, **kwargs)
+ .. classmethod:: _build(cls, model_class, *args, **kwargs)
.. OHAI_VIM*
This class method is called whenever a new instance needs to be built.
- It receives the target class (provided to :attr:`~FactoryOptions.target`), and
+ It receives the model class (provided to :attr:`~FactoryOptions.model`), and
the positional and keyword arguments to use for the class once all has
been computed.
Subclasses may override this for custom APIs.
- .. classmethod:: _create(cls, target_class, *args, **kwargs)
+ .. classmethod:: _create(cls, model_class, *args, **kwargs)
.. OHAI_VIM*
@@ -286,8 +286,8 @@ The :class:`Factory` class
class Meta:
abstract = True # Optional
- def _create(cls, target_class, *args, **kwargs):
- obj = target_class(*args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ obj = model_class(*args, **kwargs)
obj.save()
return obj
@@ -363,7 +363,7 @@ factory_boy supports two main strategies for generating instances, plus stubs.
but not persisted to any datastore.
It is usually a simple call to the :meth:`~object.__init__` method of the
- :attr:`~FactoryOptions.target` class.
+ :attr:`~FactoryOptions.model` class.
.. data:: CREATE_STRATEGY
@@ -386,7 +386,7 @@ factory_boy supports two main strategies for generating instances, plus stubs.
when using the ``create`` strategy.
That policy will be used if the
- :attr:`associated class <FactoryOptions.target>` has an ``objects``
+ :attr:`associated class <FactoryOptions.model` has an ``objects``
attribute *and* the :meth:`~Factory._create` classmethod of the
:class:`Factory` wasn't overridden.
@@ -407,7 +407,7 @@ factory_boy supports two main strategies for generating instances, plus stubs.
.. data:: STUB_STRATEGY
The 'stub' strategy is an exception in the factory_boy world: it doesn't return
- an instance of the :attr:`~FactoryOptions.target` class, and actually doesn't
+ an instance of the :attr:`~FactoryOptions.model` class, and actually doesn't
require one to be present.
Instead, it returns an instance of :class:`StubObject` whose attributes have been
@@ -485,7 +485,7 @@ accept the object being built as sole argument, and return a value.
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
username = 'john'
email = factory.LazyAttribute(lambda o: '%s@example.com' % o.username)
@@ -521,7 +521,7 @@ return value of the method:
class UserFactory(factory.Factory)
class Meta:
- target = User
+ model = User
name = u"Jean"
@@ -560,7 +560,7 @@ This declaration takes a single argument, a function accepting a single paramete
class UserFactory(factory.Factory)
class Meta:
- target = User
+ model = User
phone = factory.Sequence(lambda n: '123-555-%04d' % n)
@@ -586,7 +586,7 @@ be the sequence counter - this might be confusing:
class UserFactory(factory.Factory)
class Meta:
- target = User
+ model = User
@factory.sequence
def phone(n):
@@ -612,7 +612,7 @@ The sequence counter is shared across all :class:`Sequence` attributes of the
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
phone = factory.Sequence(lambda n: '%04d' % n)
office = factory.Sequence(lambda n: 'A23-B%03d' % n)
@@ -637,7 +637,7 @@ sequence counter is shared:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
phone = factory.Sequence(lambda n: '123-555-%04d' % n)
@@ -673,7 +673,7 @@ class-level value.
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
uid = factory.Sequence(int)
@@ -709,7 +709,7 @@ It takes a single argument, a function whose two parameters are, in order:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
login = 'john'
email = factory.LazyAttributeSequence(lambda o, n: '%s@s%d.example.com' % (o.login, n))
@@ -734,7 +734,7 @@ handles more complex cases:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
login = 'john'
@@ -772,7 +772,7 @@ The :class:`SubFactory` attribute should be called with:
class FooFactory(factory.Factory):
class Meta:
- target = Foo
+ model = Foo
bar = factory.SubFactory(BarFactory) # Not BarFactory()
@@ -786,7 +786,7 @@ Definition
# A standard factory
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
# Various fields
first_name = 'John'
@@ -796,7 +796,7 @@ Definition
# A factory for an object with a 'User' field
class CompanyFactory(factory.Factory):
class Meta:
- target = Company
+ model = Company
name = factory.Sequence(lambda n: 'FactoryBoyz' + 'z' * n)
@@ -877,14 +877,14 @@ This issue can be handled by passing the absolute import path to the target
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
username = 'john'
main_group = factory.SubFactory('users.factories.GroupFactory')
class GroupFactory(factory.Factory):
class Meta:
- target = Group
+ model = Group
name = "MyGroup"
owner = factory.SubFactory(UserFactory)
@@ -913,7 +913,7 @@ That declaration takes a single argument, a dot-delimited path to the attribute
class UserFactory(factory.Factory)
class Meta:
- target = User
+ model = User
birthdate = factory.Sequence(lambda n: datetime.date(2000, 1, 1) + datetime.timedelta(days=n))
birthmonth = factory.SelfAttribute('birthdate.month')
@@ -940,14 +940,14 @@ gains an "upward" semantic through the double-dot notation, as used in Python im
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
language = 'en'
class CompanyFactory(factory.Factory):
class Meta:
- target = Company
+ model = Company
country = factory.SubFactory(CountryFactory)
owner = factory.SubFactory(UserFactory, language=factory.SelfAttribute('..country.language'))
@@ -976,7 +976,7 @@ through the :attr:`~containers.LazyStub.factory_parent` attribute of the passed-
class CompanyFactory(factory.Factory):
class Meta:
- target = Company
+ model = Company
country = factory.SubFactory(CountryFactory)
owner = factory.SubFactory(UserFactory,
language=factory.LazyAttribute(lambda user: user.factory_parent.country.language),
@@ -1055,7 +1055,7 @@ adequate value.
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
# CATEGORY_CHOICES is a list of (key, title) tuples
category = factory.Iterator(User.CATEGORY_CHOICES, getter=lambda c: c[0])
@@ -1077,7 +1077,7 @@ use the :func:`iterator` decorator:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
@factory.iterator
def name():
@@ -1121,7 +1121,7 @@ with the :class:`Dict` and :class:`List` attributes:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
is_superuser = False
roles = factory.Dict({
@@ -1158,7 +1158,7 @@ with the :class:`Dict` and :class:`List` attributes:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
flags = factory.List([
'user',
@@ -1206,7 +1206,7 @@ For instance, a :class:`PostGeneration` hook is declared as ``post``:
class SomeFactory(factory.Factory):
class Meta:
- target = SomeObject
+ model = SomeObject
@post_generation
def post(self, create, extracted, **kwargs):
@@ -1221,7 +1221,7 @@ When calling the factory, some arguments will be extracted for this method:
- Any argument starting with ``post__XYZ`` will be extracted, its ``post__`` prefix
removed, and added to the kwargs passed to the post-generation hook.
-Extracted arguments won't be passed to the :attr:`~FactoryOptions.target` class.
+Extracted arguments won't be passed to the :attr:`~FactoryOptions.model` class.
Thus, in the following call:
@@ -1235,7 +1235,7 @@ Thus, in the following call:
)
The ``post`` hook will receive ``1`` as ``extracted`` and ``{'y': 3, 'z__t': 42}``
-as keyword arguments; ``{'post_x': 2}`` will be passed to ``SomeFactory._meta.target``.
+as keyword arguments; ``{'post_x': 2}`` will be passed to ``SomeFactory._meta.model``.
RelatedFactory
@@ -1278,7 +1278,7 @@ RelatedFactory
class FooFactory(factory.Factory):
class Meta:
- target = Foo
+ model = Foo
bar = factory.RelatedFactory(BarFactory) # Not BarFactory()
@@ -1287,14 +1287,14 @@ RelatedFactory
class CityFactory(factory.Factory):
class Meta:
- target = City
+ model = City
capital_of = None
name = "Toronto"
class CountryFactory(factory.Factory):
class Meta:
- target = Country
+ model = Country
lang = 'fr'
capital_city = factory.RelatedFactory(CityFactory, 'capital_of', name="Paris")
@@ -1336,7 +1336,7 @@ PostGeneration
.. class:: PostGeneration(callable)
-The :class:`PostGeneration` declaration performs actions once the target object
+The :class:`PostGeneration` declaration performs actions once the model object
has been generated.
Its sole argument is a callable, that will be called once the base object has
@@ -1357,7 +1357,7 @@ as ``callable(obj, create, extracted, **kwargs)``, where:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
login = 'john'
make_mbox = factory.PostGeneration(
@@ -1378,7 +1378,7 @@ A decorator is also provided, decorating a single method accepting the same
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
login = 'john'
@@ -1414,7 +1414,7 @@ PostGenerationMethodCall
.. attribute:: method_name
- The name of the method to call on the :attr:`~FactoryOptions.target` object
+ The name of the method to call on the :attr:`~FactoryOptions.model` object
.. attribute:: args
@@ -1439,7 +1439,7 @@ attribute like below:
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
username = 'user'
password = factory.PostGenerationMethodCall('set_password',
@@ -1490,7 +1490,7 @@ factory during instantiation.
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = User
+ model = User
username = 'user'
password = factory.PostGenerationMethodCall('set_password',
@@ -1505,7 +1505,7 @@ example, if we declared the ``password`` attribute like the following,
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
username = 'user'
password = factory.PostGenerationMethodCall('set_password', '', 'sha1')
@@ -1569,7 +1569,7 @@ Lightweight factory declaration
class UserFactory(factory.Factory):
class Meta:
- target = User
+ model = User
login = 'john'
email = factory.LazyAttribute(lambda u: '%s@example.com' % u.login)
@@ -1589,7 +1589,7 @@ Lightweight factory declaration
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.User
+ model = models.User
login = 'john'
email = factory.LazyAttribute(lambda u: '%s@example.com' % u.login)
diff --git a/factory/alchemy.py b/factory/alchemy.py
index b956d7e..3c91411 100644
--- a/factory/alchemy.py
+++ b/factory/alchemy.py
@@ -47,7 +47,7 @@ class SQLAlchemyModelFactory(base.Factory):
def _setup_next_sequence(cls, *args, **kwargs):
"""Compute the next available PK, based on the 'pk' database field."""
session = cls._meta.sqlalchemy_session
- model = cls._meta.target
+ model = cls._meta.model
pk = getattr(model, model.__mapper__.primary_key[0].name)
max_pk = session.query(max(pk)).one()[0]
if isinstance(max_pk, int):
@@ -56,9 +56,9 @@ class SQLAlchemyModelFactory(base.Factory):
return 1
@classmethod
- def _create(cls, target_class, *args, **kwargs):
+ def _create(cls, model_class, *args, **kwargs):
"""Create an instance of the model, and save it to the database."""
session = cls._meta.sqlalchemy_session
- obj = target_class(*args, **kwargs)
+ obj = model_class(*args, **kwargs)
session.add(obj)
return obj
diff --git a/factory/base.py b/factory/base.py
index 862556e..e5c31f7 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -41,7 +41,7 @@ class FactoryError(Exception):
class AssociatedClassError(FactoryError):
- """Exception for Factory subclasses lacking Meta.target."""
+ """Exception for Factory subclasses lacking Meta.model."""
class UnknownStrategy(FactoryError):
@@ -147,7 +147,7 @@ class FactoryMetaClass(type):
if cls._meta.abstract:
return '<%s (abstract)>' % cls.__name__
else:
- return '<%s for %s>' % (cls.__name__, cls._meta.target)
+ return '<%s for %s>' % (cls.__name__, cls._meta.model)
class BaseMeta:
@@ -189,7 +189,7 @@ class FactoryOptions(object):
to update() its return value.
"""
return [
- OptionDefault('target', None, inherit=True),
+ OptionDefault('model', None, inherit=True),
OptionDefault('abstract', False, inherit=False),
OptionDefault('strategy', CREATE_STRATEGY, inherit=True),
OptionDefault('arg_parameters', (), inherit=True),
@@ -225,8 +225,8 @@ class FactoryOptions(object):
self._fill_from_meta(meta=meta, base_meta=base_meta)
- self.target = self.factory._load_target_class(self.target)
- if self.target is None:
+ self.model = self.factory._load_model_class(self.model)
+ if self.model is None:
self.abstract = True
self.counter_reference = self._get_counter_reference()
@@ -246,10 +246,10 @@ class FactoryOptions(object):
def _get_counter_reference(self):
"""Identify which factory should be used for a shared counter."""
- if (self.target is not None
+ if (self.model is not None
and self.base_factory is not None
- and self.base_factory._meta.target is not None
- and issubclass(self.target, self.base_factory._meta.target)):
+ and self.base_factory._meta.model is not None
+ and issubclass(self.model, self.base_factory._meta.model)):
return self.base_factory
else:
return self.factory
@@ -323,7 +323,7 @@ class BaseFactory(object):
_meta = FactoryOptions()
_OLDSTYLE_ATTRIBUTES = {
- 'FACTORY_FOR': 'target',
+ 'FACTORY_FOR': 'model',
'ABSTRACT_FACTORY': 'abstract',
'FACTORY_STRATEGY': 'strategy',
'FACTORY_ARG_PARAMETERS': 'arg_parameters',
@@ -444,8 +444,8 @@ class BaseFactory(object):
return kwargs
@classmethod
- def _load_target_class(cls, class_definition):
- """Extension point for loading target classes.
+ def _load_model_class(cls, class_definition):
+ """Extension point for loading model classes.
This can be overridden in framework-specific subclasses to hook into
existing model repositories, for instance.
@@ -453,10 +453,10 @@ class BaseFactory(object):
return class_definition
@classmethod
- def _get_target_class(cls):
- """Retrieve the actual, associated target class."""
- definition = cls._meta.target
- return cls._load_target_class(definition)
+ def _get_model_class(cls):
+ """Retrieve the actual, associated model class."""
+ definition = cls._meta.model
+ return cls._load_model_class(definition)
@classmethod
def _prepare(cls, create, **kwargs):
@@ -466,7 +466,7 @@ class BaseFactory(object):
create: bool, whether to create or to build the object
**kwargs: arguments to pass to the creation function
"""
- target_class = cls._get_target_class()
+ model_class = cls._get_model_class()
kwargs = cls._adjust_kwargs(**kwargs)
# Remove 'hidden' arguments.
@@ -482,9 +482,9 @@ class BaseFactory(object):
utils.log_pprint(args, kwargs),
)
if create:
- return cls._create(target_class, *args, **kwargs)
+ return cls._create(model_class, *args, **kwargs)
else:
- return cls._build(target_class, *args, **kwargs)
+ return cls._build(model_class, *args, **kwargs)
@classmethod
def _generate(cls, create, attrs):
@@ -497,7 +497,7 @@ class BaseFactory(object):
if cls._meta.abstract:
raise FactoryError(
"Cannot generate instances of abstract factory %(f)s; "
- "Ensure %(f)s.Meta.target is set and %(f)s.Meta.abstract "
+ "Ensure %(f)s.Meta.model is set and %(f)s.Meta.abstract "
"is either not set or False." % dict(f=cls.__name__))
# Extract declarations used for post-generation
@@ -531,34 +531,34 @@ class BaseFactory(object):
pass
@classmethod
- def _build(cls, target_class, *args, **kwargs):
- """Actually build an instance of the target_class.
+ def _build(cls, model_class, *args, **kwargs):
+ """Actually build an instance of the model_class.
Customization point, will be called once the full set of args and kwargs
has been computed.
Args:
- target_class (type): the class for which an instance should be
+ model_class (type): the class for which an instance should be
built
args (tuple): arguments to use when building the class
kwargs (dict): keyword arguments to use when building the class
"""
- return target_class(*args, **kwargs)
+ return model_class(*args, **kwargs)
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- """Actually create an instance of the target_class.
+ def _create(cls, model_class, *args, **kwargs):
+ """Actually create an instance of the model_class.
Customization point, will be called once the full set of args and kwargs
has been computed.
Args:
- target_class (type): the class for which an instance should be
+ model_class (type): the class for which an instance should be
created
args (tuple): arguments to use when creating the class
kwargs (dict): keyword arguments to use when creating the class
"""
- return target_class(*args, **kwargs)
+ return model_class(*args, **kwargs)
@classmethod
def build(cls, **kwargs):
@@ -705,7 +705,7 @@ class StubFactory(Factory):
class Meta:
strategy = STUB_STRATEGY
- target = containers.StubObject
+ model = containers.StubObject
@classmethod
def build(cls, **kwargs):
@@ -722,20 +722,20 @@ class BaseDictFactory(Factory):
abstract = True
@classmethod
- def _build(cls, target_class, *args, **kwargs):
+ def _build(cls, model_class, *args, **kwargs):
if args:
raise ValueError(
"DictFactory %r does not support Meta.arg_parameters.", cls)
- return target_class(**kwargs)
+ return model_class(**kwargs)
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- return cls._build(target_class, *args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ return cls._build(model_class, *args, **kwargs)
class DictFactory(BaseDictFactory):
class Meta:
- target = dict
+ model = dict
class BaseListFactory(Factory):
@@ -744,22 +744,22 @@ class BaseListFactory(Factory):
abstract = True
@classmethod
- def _build(cls, target_class, *args, **kwargs):
+ def _build(cls, model_class, *args, **kwargs):
if args:
raise ValueError(
"ListFactory %r does not support Meta.arg_parameters.", cls)
values = [v for k, v in sorted(kwargs.items())]
- return target_class(values)
+ return model_class(values)
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- return cls._build(target_class, *args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ return cls._build(model_class, *args, **kwargs)
class ListFactory(BaseListFactory):
class Meta:
- target = list
+ model = list
def use_strategy(new_strategy):
diff --git a/factory/containers.py b/factory/containers.py
index c0c5e24..5116320 100644
--- a/factory/containers.py
+++ b/factory/containers.py
@@ -47,27 +47,27 @@ class LazyStub(object):
__containers (LazyStub list): "parents" of the LazyStub being built.
This allows to have the field of a field depend on the value of
another field
- __target_class (type): the target class to build.
+ __model_class (type): the model class to build.
"""
__initialized = False
- def __init__(self, attrs, containers=(), target_class=object, log_ctx=None):
+ def __init__(self, attrs, containers=(), model_class=object, log_ctx=None):
self.__attrs = attrs
self.__values = {}
self.__pending = []
self.__containers = containers
- self.__target_class = target_class
- self.__log_ctx = log_ctx or '%s.%s' % (target_class.__module__, target_class.__name__)
+ self.__model_class = model_class
+ self.__log_ctx = log_ctx or '%s.%s' % (model_class.__module__, model_class.__name__)
self.factory_parent = containers[0] if containers else None
self.__initialized = True
def __repr__(self):
- return '<LazyStub for %s.%s>' % (self.__target_class.__module__, self.__target_class.__name__)
+ return '<LazyStub for %s.%s>' % (self.__model_class.__module__, self.__model_class.__name__)
def __str__(self):
return '<LazyStub for %s with %s>' % (
- self.__target_class.__name__, list(self.__attrs.keys()))
+ self.__model_class.__name__, list(self.__attrs.keys()))
def __fill__(self):
"""Fill this LazyStub, computing values of all defined attributes.
@@ -224,7 +224,7 @@ class AttributeBuilder(object):
wrapped_attrs[k] = v
stub = LazyStub(wrapped_attrs, containers=self._containers,
- target_class=self.factory, log_ctx=self._log_ctx)
+ model_class=self.factory, log_ctx=self._log_ctx)
return stub.__fill__()
diff --git a/factory/declarations.py b/factory/declarations.py
index 037a679..5e7e734 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -50,7 +50,7 @@ class OrderedDeclaration(object):
attributes
containers (list of containers.LazyStub): The chain of SubFactory
which led to building this object.
- create (bool): whether the target class should be 'built' or
+ create (bool): whether the model class should be 'built' or
'created'
extra (DeclarationDict or None): extracted key/value extracted from
the attribute prefix
@@ -434,7 +434,7 @@ class ExtractionContext(object):
class PostGenerationDeclaration(object):
- """Declarations to be called once the target object has been generated."""
+ """Declarations to be called once the model object has been generated."""
def extract(self, name, attrs):
"""Extract relevant attributes from a dict.
diff --git a/factory/django.py b/factory/django.py
index 77afd8c..6090145 100644
--- a/factory/django.py
+++ b/factory/django.py
@@ -61,10 +61,10 @@ class DjangoOptions(base.FactoryOptions):
def _get_counter_reference(self):
counter_reference = super(DjangoOptions, self)._get_counter_reference()
if (counter_reference == self.base_factory
- and self.base_factory._meta.target is not None
- and self.base_factory._meta.target._meta.abstract
- and self.target is not None
- and not self.target._meta.abstract):
+ and self.base_factory._meta.model is not None
+ and self.base_factory._meta.model._meta.abstract
+ and self.model is not None
+ and not self.model._meta.abstract):
# Target factory is for an abstract model, yet we're for another,
# concrete subclass => don't reuse the counter.
return self.factory
@@ -90,7 +90,7 @@ class DjangoModelFactory(base.Factory):
})
@classmethod
- def _load_target_class(cls, definition):
+ def _load_model_class(cls, definition):
if is_string(definition) and '.' in definition:
app, model = definition.split('.', 1)
@@ -100,17 +100,17 @@ class DjangoModelFactory(base.Factory):
return definition
@classmethod
- def _get_manager(cls, target_class):
+ def _get_manager(cls, model_class):
try:
- return target_class._default_manager # pylint: disable=W0212
+ return model_class._default_manager # pylint: disable=W0212
except AttributeError:
- return target_class.objects
+ return model_class.objects
@classmethod
def _setup_next_sequence(cls):
"""Compute the next available PK, based on the 'pk' database field."""
- model = cls._get_target_class() # pylint: disable=E1101
+ model = cls._get_model_class() # pylint: disable=E1101
manager = cls._get_manager(model)
try:
@@ -122,9 +122,9 @@ class DjangoModelFactory(base.Factory):
return 1
@classmethod
- def _get_or_create(cls, target_class, *args, **kwargs):
+ def _get_or_create(cls, model_class, *args, **kwargs):
"""Create an instance of the model through objects.get_or_create."""
- manager = cls._get_manager(target_class)
+ manager = cls._get_manager(model_class)
assert 'defaults' not in cls._meta.django_get_or_create, (
"'defaults' is a reserved keyword for get_or_create "
@@ -140,12 +140,12 @@ class DjangoModelFactory(base.Factory):
return obj
@classmethod
- def _create(cls, target_class, *args, **kwargs):
+ def _create(cls, model_class, *args, **kwargs):
"""Create an instance of the model, and save it to the database."""
- manager = cls._get_manager(target_class)
+ manager = cls._get_manager(model_class)
if cls._meta.django_get_or_create:
- return cls._get_or_create(target_class, *args, **kwargs)
+ return cls._get_or_create(model_class, *args, **kwargs)
return manager.create(*args, **kwargs)
diff --git a/factory/helpers.py b/factory/helpers.py
index 0c387d0..19431df 100644
--- a/factory/helpers.py
+++ b/factory/helpers.py
@@ -51,7 +51,7 @@ def make_factory(klass, **kwargs):
"""Create a new, simple factory for the given class."""
factory_name = '%sFactory' % klass.__name__
class Meta:
- target = klass
+ model = klass
kwargs['Meta'] = Meta
base_class = kwargs.pop('FACTORY_CLASS', base.Factory)
diff --git a/factory/mogo.py b/factory/mogo.py
index 0214119..5541043 100644
--- a/factory/mogo.py
+++ b/factory/mogo.py
@@ -36,11 +36,11 @@ class MogoFactory(base.Factory):
abstract = True
@classmethod
- def _build(cls, target_class, *args, **kwargs):
- return target_class.new(*args, **kwargs)
+ def _build(cls, model_class, *args, **kwargs):
+ return model_class.new(*args, **kwargs)
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- instance = target_class.new(*args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ instance = model_class.new(*args, **kwargs)
instance.save()
return instance
diff --git a/factory/mongoengine.py b/factory/mongoengine.py
index 729ebb1..e3ab99c 100644
--- a/factory/mongoengine.py
+++ b/factory/mongoengine.py
@@ -37,12 +37,12 @@ class MongoEngineFactory(base.Factory):
abstract = True
@classmethod
- def _build(cls, target_class, *args, **kwargs):
- return target_class(*args, **kwargs)
+ def _build(cls, model_class, *args, **kwargs):
+ return model_class(*args, **kwargs)
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- instance = target_class(*args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ instance = model_class(*args, **kwargs)
if instance._is_document:
instance.save()
return instance
diff --git a/tests/cyclic/bar.py b/tests/cyclic/bar.py
index 8674c4d..a5e6bf1 100644
--- a/tests/cyclic/bar.py
+++ b/tests/cyclic/bar.py
@@ -31,7 +31,7 @@ class Bar(object):
class BarFactory(factory.Factory):
class Meta:
- target = Bar
+ model = Bar
y = 13
foo = factory.SubFactory('cyclic.foo.FooFactory')
diff --git a/tests/cyclic/foo.py b/tests/cyclic/foo.py
index 5310b1e..18de362 100644
--- a/tests/cyclic/foo.py
+++ b/tests/cyclic/foo.py
@@ -33,7 +33,7 @@ class Foo(object):
class FooFactory(factory.Factory):
class Meta:
- target = Foo
+ model = Foo
x = 42
bar = factory.SubFactory(bar_mod.BarFactory)
diff --git a/tests/test_alchemy.py b/tests/test_alchemy.py
index 4526ad1..b9222eb 100644
--- a/tests/test_alchemy.py
+++ b/tests/test_alchemy.py
@@ -48,7 +48,7 @@ else:
class StandardFactory(SQLAlchemyModelFactory):
class Meta:
- target = models.StandardModel
+ model = models.StandardModel
sqlalchemy_session = models.session
id = factory.Sequence(lambda n: n)
@@ -57,7 +57,7 @@ class StandardFactory(SQLAlchemyModelFactory):
class NonIntegerPkFactory(SQLAlchemyModelFactory):
class Meta:
- target = models.NonIntegerPk
+ model = models.NonIntegerPk
sqlalchemy_session = models.session
id = factory.Sequence(lambda n: 'foo%d' % n)
diff --git a/tests/test_base.py b/tests/test_base.py
index c44ebd5..d93bf29 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -53,8 +53,8 @@ class FakeModelFactory(base.Factory):
abstract = True
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- return target_class.create(**kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ return model_class.create(**kwargs)
class TestModel(FakeDjangoModel):
@@ -68,13 +68,13 @@ class SafetyTestCase(unittest.TestCase):
class AbstractFactoryTestCase(unittest.TestCase):
def test_factory_for_optional(self):
- """Ensure that target= is optional for abstract=True."""
+ """Ensure that model= is optional for abstract=True."""
class TestObjectFactory(base.Factory):
class Meta:
abstract = True
self.assertTrue(TestObjectFactory._meta.abstract)
- self.assertIsNone(TestObjectFactory._meta.target)
+ self.assertIsNone(TestObjectFactory._meta.model)
def test_factory_for_and_abstract_factory_optional(self):
"""Ensure that Meta.abstract is optional."""
@@ -82,7 +82,7 @@ class AbstractFactoryTestCase(unittest.TestCase):
pass
self.assertTrue(TestObjectFactory._meta.abstract)
- self.assertIsNone(TestObjectFactory._meta.target)
+ self.assertIsNone(TestObjectFactory._meta.model)
def test_abstract_factory_cannot_be_called(self):
class TestObjectFactory(base.Factory):
@@ -97,18 +97,18 @@ class AbstractFactoryTestCase(unittest.TestCase):
class TestObjectFactory(base.Factory):
class Meta:
abstract = True
- target = TestObject
+ model = TestObject
class TestObjectChildFactory(TestObjectFactory):
pass
self.assertFalse(TestObjectChildFactory._meta.abstract)
- def test_abstract_or_target_is_required(self):
+ def test_abstract_or_model_is_required(self):
class TestObjectFactory(base.Factory):
class Meta:
abstract = False
- target = None
+ model = None
self.assertRaises(base.FactoryError, TestObjectFactory.build)
self.assertRaises(base.FactoryError, TestObjectFactory.create)
@@ -121,7 +121,7 @@ class OptionsTests(unittest.TestCase):
# Declarative attributes
self.assertTrue(AbstractFactory._meta.abstract)
- self.assertIsNone(AbstractFactory._meta.target)
+ self.assertIsNone(AbstractFactory._meta.model)
self.assertEqual((), AbstractFactory._meta.arg_parameters)
self.assertEqual((), AbstractFactory._meta.hidden_args)
self.assertEqual(base.CREATE_STRATEGY, AbstractFactory._meta.strategy)
@@ -206,7 +206,7 @@ class DeclarationParsingTests(unittest.TestCase):
def test_classmethod(self):
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@classmethod
def some_classmethod(cls):
@@ -222,16 +222,16 @@ class FactoryTestCase(unittest.TestCase):
"""Calling a FooFactory doesn't yield a FooFactory instance."""
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
- self.assertEqual(TestObject, TestObjectFactory._meta.target)
+ self.assertEqual(TestObject, TestObjectFactory._meta.model)
obj = TestObjectFactory.build()
self.assertFalse(hasattr(obj, '_meta'))
def test_display(self):
class TestObjectFactory(base.Factory):
class Meta:
- target = FakeDjangoModel
+ model = FakeDjangoModel
self.assertIn('TestObjectFactory', str(TestObjectFactory))
self.assertIn('FakeDjangoModel', str(TestObjectFactory))
@@ -239,7 +239,7 @@ class FactoryTestCase(unittest.TestCase):
def test_lazy_attribute_non_existent_param(self):
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = declarations.LazyAttribute(lambda a: a.does_not_exist )
@@ -249,13 +249,13 @@ class FactoryTestCase(unittest.TestCase):
"""Tests that sequence IDs are shared between parent and son."""
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = declarations.Sequence(lambda a: a)
class TestSubFactory(TestObjectFactory):
class Meta:
- target = TestObject
+ model = TestObject
pass
@@ -273,7 +273,7 @@ class FactorySequenceTestCase(unittest.TestCase):
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = declarations.Sequence(lambda n: n)
self.TestObjectFactory = TestObjectFactory
@@ -358,7 +358,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
class TestModelFactory(base.Factory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -371,7 +371,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -384,7 +384,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
class TestModelFactory(base.Factory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -397,7 +397,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
class TestModelFactory(base.Factory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -406,7 +406,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
def test_stub_with_non_stub_strategy(self):
class TestModelFactory(base.StubFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -421,7 +421,7 @@ class FactoryDefaultStrategyTestCase(unittest.TestCase):
@base.use_strategy(base.CREATE_STRATEGY)
class TestModelFactory(base.StubFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -432,7 +432,7 @@ class FactoryCreationTestCase(unittest.TestCase):
def test_factory_for(self):
class TestFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
self.assertTrue(isinstance(TestFactory.build(), TestObject))
@@ -445,7 +445,7 @@ class FactoryCreationTestCase(unittest.TestCase):
def test_inheritance_with_stub(self):
class TestObjectFactory(base.StubFactory):
class Meta:
- target = TestObject
+ model = TestObject
pass
@@ -457,7 +457,7 @@ class FactoryCreationTestCase(unittest.TestCase):
def test_custom_creation(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
@classmethod
def _prepare(cls, create, **kwargs):
@@ -488,7 +488,7 @@ class PostGenerationParsingTestCase(unittest.TestCase):
def test_extraction(self):
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
foo = declarations.PostGenerationDeclaration()
@@ -497,7 +497,7 @@ class PostGenerationParsingTestCase(unittest.TestCase):
def test_classlevel_extraction(self):
class TestObjectFactory(base.Factory):
class Meta:
- target = TestObject
+ model = TestObject
foo = declarations.PostGenerationDeclaration()
foo__bar = 42
diff --git a/tests/test_containers.py b/tests/test_containers.py
index 8a9e990..bd7019e 100644
--- a/tests/test_containers.py
+++ b/tests/test_containers.py
@@ -94,7 +94,7 @@ class LazyStubTestCase(unittest.TestCase):
class RandomObj(object):
pass
- stub = containers.LazyStub({'one': 1, 'two': 2}, target_class=RandomObj)
+ stub = containers.LazyStub({'one': 1, 'two': 2}, model_class=RandomObj)
self.assertIn('RandomObj', repr(stub))
self.assertIn('RandomObj', str(stub))
self.assertIn('one', str(stub))
diff --git a/tests/test_deprecation.py b/tests/test_deprecation.py
index bccc351..bad6104 100644
--- a/tests/test_deprecation.py
+++ b/tests/test_deprecation.py
@@ -46,4 +46,4 @@ class DeprecationTests(unittest.TestCase):
# This is to ensure error messages are readable by end users.
self.assertEqual(__file__, warning.filename)
self.assertIn('FACTORY_FOR', str(warning.message))
- self.assertIn('target', str(warning.message))
+ self.assertIn('model', str(warning.message))
diff --git a/tests/test_django.py b/tests/test_django.py
index 2bc5fe2..84b0933 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -100,14 +100,14 @@ def tearDownModule():
class StandardFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.StandardModel
+ model = models.StandardModel
foo = factory.Sequence(lambda n: "foo%d" % n)
class StandardFactoryWithPKField(factory.django.DjangoModelFactory):
class Meta:
- target = models.StandardModel
+ model = models.StandardModel
django_get_or_create = ('pk',)
foo = factory.Sequence(lambda n: "foo%d" % n)
@@ -116,7 +116,7 @@ class StandardFactoryWithPKField(factory.django.DjangoModelFactory):
class NonIntegerPkFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.NonIntegerPk
+ model = models.NonIntegerPk
foo = factory.Sequence(lambda n: "foo%d" % n)
bar = ''
@@ -124,7 +124,7 @@ class NonIntegerPkFactory(factory.django.DjangoModelFactory):
class AbstractBaseFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.AbstractBase
+ model = models.AbstractBase
abstract = True
foo = factory.Sequence(lambda n: "foo%d" % n)
@@ -132,22 +132,22 @@ class AbstractBaseFactory(factory.django.DjangoModelFactory):
class ConcreteSonFactory(AbstractBaseFactory):
class Meta:
- target = models.ConcreteSon
+ model = models.ConcreteSon
class AbstractSonFactory(AbstractBaseFactory):
class Meta:
- target = models.AbstractSon
+ model = models.AbstractSon
class ConcreteGrandSonFactory(AbstractBaseFactory):
class Meta:
- target = models.ConcreteGrandSon
+ model = models.ConcreteGrandSon
class WithFileFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.WithFile
+ model = models.WithFile
if django is not None:
afile = factory.django.FileField()
@@ -155,7 +155,7 @@ class WithFileFactory(factory.django.DjangoModelFactory):
class WithImageFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.WithImage
+ model = models.WithImage
if django is not None:
animage = factory.django.ImageField()
@@ -163,7 +163,7 @@ class WithImageFactory(factory.django.DjangoModelFactory):
class WithSignalsFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.WithSignals
+ model = models.WithSignals
@unittest.skipIf(django is None, "Django not installed.")
@@ -231,19 +231,19 @@ class DjangoPkForceTestCase(django_test.TestCase):
@unittest.skipIf(django is None, "Django not installed.")
class DjangoModelLoadingTestCase(django_test.TestCase):
"""Tests class Meta:
- target = 'app.Model' pattern."""
+ model = 'app.Model' pattern."""
def test_loading(self):
class ExampleFactory(factory.DjangoModelFactory):
class Meta:
- target = 'djapp.StandardModel'
+ model = 'djapp.StandardModel'
- self.assertEqual(models.StandardModel, ExampleFactory._get_target_class())
+ self.assertEqual(models.StandardModel, ExampleFactory._get_model_class())
def test_building(self):
class ExampleFactory(factory.DjangoModelFactory):
class Meta:
- target = 'djapp.StandardModel'
+ model = 'djapp.StandardModel'
e = ExampleFactory.build()
self.assertEqual(models.StandardModel, e.__class__)
@@ -255,7 +255,7 @@ class DjangoModelLoadingTestCase(django_test.TestCase):
"""
class ExampleFactory(factory.DjangoModelFactory):
class Meta:
- target = 'djapp.StandardModel'
+ model = 'djapp.StandardModel'
class Example2Factory(ExampleFactory):
pass
@@ -270,15 +270,15 @@ class DjangoModelLoadingTestCase(django_test.TestCase):
"""
class ExampleFactory(factory.DjangoModelFactory):
class Meta:
- target = 'djapp.StandardModel'
+ model = 'djapp.StandardModel'
foo = factory.Sequence(lambda n: n)
class Example2Factory(ExampleFactory):
class Meta:
- target = 'djapp.StandardSon'
+ model = 'djapp.StandardSon'
- self.assertEqual(models.StandardSon, Example2Factory._get_target_class())
+ self.assertEqual(models.StandardSon, Example2Factory._get_model_class())
e1 = ExampleFactory.build()
e2 = Example2Factory.build()
@@ -580,7 +580,7 @@ class PreventSignalsTestCase(unittest.TestCase):
@factory.django.mute_signals(signals.pre_save, signals.post_save)
class WithSignalsDecoratedFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.WithSignals
+ model = models.WithSignals
WithSignalsDecoratedFactory()
@@ -594,7 +594,7 @@ class PreventSignalsTestCase(unittest.TestCase):
@factory.django.mute_signals(signals.pre_save, signals.post_save)
class WithSignalsDecoratedFactory(factory.django.DjangoModelFactory):
class Meta:
- target = models.WithSignals
+ model = models.WithSignals
WithSignalsDecoratedFactory.build()
diff --git a/tests/test_mongoengine.py b/tests/test_mongoengine.py
index 39594c0..988c179 100644
--- a/tests/test_mongoengine.py
+++ b/tests/test_mongoengine.py
@@ -43,13 +43,13 @@ if mongoengine:
class AddressFactory(MongoEngineFactory):
class Meta:
- target = Address
+ model = Address
street = factory.Sequence(lambda n: 'street%d' % n)
class PersonFactory(MongoEngineFactory):
class Meta:
- target = Person
+ model = Person
name = factory.Sequence(lambda n: 'name%d' % n)
address = factory.SubFactory(AddressFactory)
diff --git a/tests/test_using.py b/tests/test_using.py
index 6e7ed64..5486d33 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -82,8 +82,8 @@ class FakeModelFactory(factory.Factory):
abstract = True
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- return target_class.create(**kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ return model_class.create(**kwargs)
class TestModel(FakeModel):
@@ -294,18 +294,18 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_attribute(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
test_object = TestObjectFactory.build()
self.assertEqual(test_object.one, 'one')
- def test_inheriting_target_class(self):
+ def test_inheriting_model_class(self):
@factory.use_strategy(factory.BUILD_STRATEGY)
class TestObjectFactory(factory.Factory, TestObject):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
@@ -321,7 +321,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class InheritedFactory(SomeAbstractFactory):
class Meta:
- target = TestObject
+ model = TestObject
test_object = InheritedFactory.build()
self.assertEqual(test_object.one, 'one')
@@ -329,7 +329,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_sequence(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: 'one%d' % n)
two = factory.Sequence(lambda n: 'two%d' % n)
@@ -345,7 +345,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_sequence_custom_begin(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@classmethod
def _setup_next_sequence(cls):
@@ -365,7 +365,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_sequence_override(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: 'one%d' % n)
@@ -382,13 +382,13 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_custom_create(self):
class TestModelFactory(factory.Factory):
class Meta:
- target = TestModel
+ model = TestModel
two = 2
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- obj = target_class.create(**kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ obj = model_class.create(**kwargs)
obj.properly_created = True
return obj
@@ -406,7 +406,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class NonDjangoFactory(factory.Factory):
class Meta:
- target = NonDjango
+ model = NonDjango
x = 3
@@ -417,7 +417,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_sequence_batch(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: 'one%d' % n)
two = factory.Sequence(lambda n: 'two%d' % n)
@@ -433,7 +433,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_lazy_attribute(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.LazyAttribute(lambda a: 'abc' )
two = factory.LazyAttribute(lambda a: a.one + ' xyz')
@@ -445,7 +445,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_lazy_attribute_sequence(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.LazyAttributeSequence(lambda a, n: 'abc%d' % n)
two = factory.LazyAttributeSequence(lambda a, n: a.one + ' xyz%d' % n)
@@ -461,7 +461,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_lazy_attribute_decorator(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@factory.lazy_attribute
def one(a):
@@ -476,7 +476,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'xx'
two = factory.SelfAttribute('one')
@@ -496,13 +496,13 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 3
three = factory.SelfAttribute('..bar')
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
bar = 4
two = factory.SubFactory(TestModelFactory, one=1)
@@ -512,7 +512,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_sequence_decorator(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@factory.sequence
def one(n):
@@ -524,7 +524,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_lazy_attribute_sequence_decorator(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@factory.lazy_attribute_sequence
def one(a, n):
@@ -540,7 +540,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_build_with_parameters(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: 'one%d' % n)
two = factory.Sequence(lambda n: 'two%d' % n)
@@ -557,7 +557,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_create(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -568,7 +568,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_create_batch(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -585,7 +585,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_build(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -596,7 +596,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_create(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -607,7 +607,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_stub(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -618,7 +618,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_batch_build(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -635,7 +635,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_batch_create(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -652,7 +652,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_generate_batch_stub(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -669,7 +669,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_simple_generate_build(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -680,7 +680,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_simple_generate_create(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -691,7 +691,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_simple_generate_batch_build(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -708,7 +708,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_simple_generate_batch_create(self):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 'one'
@@ -725,7 +725,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_stub_batch(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
two = factory.LazyAttribute(lambda a: a.one + ' two')
@@ -745,14 +745,14 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_inheritance(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
two = factory.LazyAttribute(lambda a: a.one + ' two')
class TestObjectFactory2(TestObjectFactory):
class Meta:
- target = TestObject
+ model = TestObject
three = 'three'
four = factory.LazyAttribute(lambda a: a.three + ' four')
@@ -770,13 +770,13 @@ class UsingFactoryTestCase(unittest.TestCase):
"""Sequence counters should be kept within an inheritance chain."""
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: n)
class TestObjectFactory2(TestObjectFactory):
class Meta:
- target = TestObject
+ model = TestObject
to1a = TestObjectFactory()
self.assertEqual(0, to1a.one)
@@ -794,13 +794,13 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: n)
class TestObjectFactory2(TestObjectFactory):
class Meta:
- target = TestObject2
+ model = TestObject2
to1a = TestObjectFactory()
self.assertEqual(0, to1a.one)
@@ -826,13 +826,13 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: n)
class TestObjectFactory2(TestObjectFactory):
class Meta:
- target = TestObject2
+ model = TestObject2
to1a = TestObjectFactory()
self.assertEqual(0, to1a.one)
@@ -847,7 +847,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_inheritance_with_inherited_class(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
two = factory.LazyAttribute(lambda a: a.one + ' two')
@@ -865,13 +865,13 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_dual_inheritance(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 'one'
class TestOtherFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 'two'
four = 'four'
@@ -887,7 +887,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_class_method_accessible(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@classmethod
def alt_create(cls, **kwargs):
@@ -898,7 +898,7 @@ class UsingFactoryTestCase(unittest.TestCase):
def test_static_method_accessible(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@staticmethod
def alt_create(**kwargs):
@@ -914,7 +914,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
arg_parameters = ('x', 'y')
x = 1
@@ -934,7 +934,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
hidden_args = ('x', 'z')
x = 1
@@ -954,7 +954,7 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
hidden_args = ('x', 'z')
arg_parameters = ('y',)
@@ -978,7 +978,7 @@ class NonKwargParametersTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
arg_parameters = ('one', 'two',)
one = 1
@@ -1004,7 +1004,7 @@ class NonKwargParametersTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
arg_parameters = ('one', 'two')
one = 1
@@ -1012,8 +1012,8 @@ class NonKwargParametersTestCase(unittest.TestCase):
three = 3
@classmethod
- def _create(cls, target_class, *args, **kwargs):
- return target_class.create(*args, **kwargs)
+ def _create(cls, model_class, *args, **kwargs):
+ return model_class.create(*args, **kwargs)
obj = TestObjectFactory.create()
self.assertEqual((1, 2), obj.args)
@@ -1031,7 +1031,7 @@ class KwargAdjustTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@classmethod
def _adjust_kwargs(cls, **kwargs):
@@ -1050,12 +1050,12 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 3
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
two = factory.SubFactory(TestModelFactory, one=1)
test_model = TestModel2Factory(two__one=4)
@@ -1069,11 +1069,11 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
two = factory.SubFactory(TestModelFactory,
one=factory.Sequence(lambda n: 'x%dx' % n),
two=factory.LazyAttribute(lambda o: '%s%s' % (o.one, o.one)),
@@ -1091,13 +1091,13 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Sequence(lambda n: int(n))
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrapped = factory.SubFactory(TestObjectFactory)
@@ -1114,7 +1114,7 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
class OtherTestObject(object):
@@ -1124,7 +1124,7 @@ class SubFactoryTestCase(unittest.TestCase):
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = OtherTestObject
+ model = OtherTestObject
wrapped = factory.SubFactory(TestObjectFactory, two=2, four=4)
wrapped__two = 4
@@ -1145,18 +1145,18 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrapped = factory.SubFactory(TestObjectFactory)
wrapped_bis = factory.SubFactory(TestObjectFactory, one=1)
class OuterWrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrap = factory.SubFactory(WrappingTestObjectFactory, wrapped__two=2)
@@ -1174,19 +1174,19 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 'two'
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrapped = factory.SubFactory(TestObjectFactory)
friend = factory.LazyAttribute(lambda o: o.wrapped.two.four + 1)
class OuterWrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrap = factory.SubFactory(WrappingTestObjectFactory,
wrapped__two=factory.SubFactory(TestObjectFactory, four=4))
@@ -1207,13 +1207,13 @@ class SubFactoryTestCase(unittest.TestCase):
# Innermost factory
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 'two'
# Intermediary factory
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrapped = factory.SubFactory(TestObjectFactory)
wrapped__two = 'three'
@@ -1232,12 +1232,12 @@ class SubFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 'two'
class WrappingTestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
wrapped = factory.SubFactory(TestObjectFactory)
friend = factory.LazyAttribute(lambda o: o.wrapped.two + 1)
@@ -1272,23 +1272,23 @@ class SubFactoryTestCase(unittest.TestCase):
class InnerMostFactory(factory.Factory):
class Meta:
- target = InnerMost
+ model = InnerMost
a = 15
b = 20
class SideAFactory(factory.Factory):
class Meta:
- target = SideA
+ model = SideA
inner_from_a = factory.SubFactory(InnerMostFactory, a=20)
class SideBFactory(factory.Factory):
class Meta:
- target = SideB
+ model = SideB
inner_from_b = factory.SubFactory(InnerMostFactory, b=15)
class OuterMostFactory(factory.Factory):
class Meta:
- target = OuterMost
+ model = OuterMost
foo = 30
side_a = factory.SubFactory(SideAFactory,
@@ -1314,13 +1314,13 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 3
two = factory.ContainerAttribute(lambda obj, containers: len(containers or []), strict=False)
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
one = 1
two = factory.SubFactory(TestModelFactory, one=1)
@@ -1339,13 +1339,13 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 3
two = factory.ContainerAttribute(lambda obj, containers: len(containers or []), strict=True)
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
one = 1
two = factory.SubFactory(TestModelFactory, one=1)
@@ -1362,7 +1362,7 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModelFactory(FakeModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
one = 3
@factory.container_attribute
@@ -1373,7 +1373,7 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModel2Factory(FakeModelFactory):
class Meta:
- target = TestModel2
+ model = TestModel2
one = 1
two = factory.SubFactory(TestModelFactory, one=1)
@@ -1392,7 +1392,7 @@ class IteratorTestCase(unittest.TestCase):
def test_iterator(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Iterator(range(10, 30))
@@ -1406,7 +1406,7 @@ class IteratorTestCase(unittest.TestCase):
def test_iterator_list_comprehension_scope_bleeding(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Iterator([j * 3 for j in range(5)])
@@ -1418,7 +1418,7 @@ class IteratorTestCase(unittest.TestCase):
def test_iterator_list_comprehension_protected(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Iterator([_j * 3 for _j in range(5)])
@@ -1432,7 +1432,7 @@ class IteratorTestCase(unittest.TestCase):
def test_iterator_decorator(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
@factory.iterator
def one():
@@ -1483,7 +1483,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
def test_simple(self):
class FakeModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = FakeModel
+ model = FakeModel
obj = FakeModelFactory(one=1)
self.assertEqual(1, obj.one)
@@ -1498,7 +1498,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
class MyFakeModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = MyFakeModel
+ model = MyFakeModel
django_get_or_create = ('x',)
x = 1
y = 4
@@ -1520,7 +1520,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
class MyFakeModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = MyFakeModel
+ model = MyFakeModel
django_get_or_create = ('x', 'y', 'z')
x = 1
y = 4
@@ -1542,7 +1542,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
class MyFakeModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = MyFakeModel
+ model = MyFakeModel
django_get_or_create = ('x',)
x = 1
y = 4
@@ -1564,7 +1564,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
class MyFakeModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = MyFakeModel
+ model = MyFakeModel
django_get_or_create = ('x', 'y', 'z')
x = 1
y = 4
@@ -1580,7 +1580,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
def test_sequence(self):
class TestModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
a = factory.Sequence(lambda n: 'foo_%s' % n)
@@ -1599,7 +1599,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
def test_no_get_or_create(self):
class TestModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
a = factory.Sequence(lambda n: 'foo_%s' % n)
@@ -1611,7 +1611,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
def test_get_or_create(self):
class TestModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
django_get_or_create = ('a', 'b')
a = factory.Sequence(lambda n: 'foo_%s' % n)
@@ -1631,7 +1631,7 @@ class DjangoModelFactoryTestCase(unittest.TestCase):
"""Test a DjangoModelFactory with all fields in get_or_create."""
class TestModelFactory(factory.django.DjangoModelFactory):
class Meta:
- target = TestModel
+ model = TestModel
django_get_or_create = ('a', 'b', 'c', 'd')
a = factory.Sequence(lambda n: 'foo_%s' % n)
@@ -1652,7 +1652,7 @@ class PostGenerationTestCase(unittest.TestCase):
def test_post_generation(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 1
@@ -1671,7 +1671,7 @@ class PostGenerationTestCase(unittest.TestCase):
def test_post_generation_hook(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 1
@@ -1693,7 +1693,7 @@ class PostGenerationTestCase(unittest.TestCase):
def test_post_generation_extraction(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 1
@@ -1719,7 +1719,7 @@ class PostGenerationTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
bar = factory.PostGeneration(my_lambda)
@@ -1739,7 +1739,7 @@ class PostGenerationTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 3
two = 2
post_call = factory.PostGenerationMethodCall('call', one=1)
@@ -1764,13 +1764,13 @@ class PostGenerationTestCase(unittest.TestCase):
class TestRelatedObjectFactory(factory.Factory):
class Meta:
- target = TestRelatedObject
+ model = TestRelatedObject
one = 1
two = factory.LazyAttribute(lambda o: o.one + 1)
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 3
two = 2
three = factory.RelatedFactory(TestRelatedObjectFactory, name='obj')
@@ -1811,13 +1811,13 @@ class PostGenerationTestCase(unittest.TestCase):
class TestRelatedObjectFactory(factory.Factory):
class Meta:
- target = TestRelatedObject
+ model = TestRelatedObject
one = 1
two = factory.LazyAttribute(lambda o: o.one + 1)
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 3
two = 2
three = factory.RelatedFactory(TestRelatedObjectFactory)
@@ -1859,11 +1859,11 @@ class RelatedFactoryExtractionTestCase(unittest.TestCase):
class TestRelatedObjectFactory(factory.Factory):
class Meta:
- target = TestRelatedObject
+ model = TestRelatedObject
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.RelatedFactory(TestRelatedObjectFactory, 'obj')
self.TestRelatedObject = TestRelatedObject
@@ -1911,7 +1911,7 @@ class DictTestCase(unittest.TestCase):
def test_empty_dict(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Dict({})
o = TestObjectFactory()
@@ -1920,7 +1920,7 @@ class DictTestCase(unittest.TestCase):
def test_naive_dict(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Dict({'a': 1})
o = TestObjectFactory()
@@ -1929,7 +1929,7 @@ class DictTestCase(unittest.TestCase):
def test_sequence_dict(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Dict({'a': factory.Sequence(lambda n: n + 2)})
o1 = TestObjectFactory()
@@ -1941,7 +1941,7 @@ class DictTestCase(unittest.TestCase):
def test_dict_override(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Dict({'a': 1})
o = TestObjectFactory(one__a=2)
@@ -1950,7 +1950,7 @@ class DictTestCase(unittest.TestCase):
def test_dict_extra_key(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.Dict({'a': 1})
o = TestObjectFactory(one__b=2)
@@ -1959,7 +1959,7 @@ class DictTestCase(unittest.TestCase):
def test_dict_merged_fields(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 13
one = factory.Dict({
'one': 1,
@@ -1973,7 +1973,7 @@ class DictTestCase(unittest.TestCase):
def test_nested_dicts(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 1
two = factory.Dict({
'one': 3,
@@ -2002,7 +2002,7 @@ class ListTestCase(unittest.TestCase):
def test_empty_list(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.List([])
o = TestObjectFactory()
@@ -2011,7 +2011,7 @@ class ListTestCase(unittest.TestCase):
def test_naive_list(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.List([1])
o = TestObjectFactory()
@@ -2020,7 +2020,7 @@ class ListTestCase(unittest.TestCase):
def test_sequence_list(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.List([factory.Sequence(lambda n: n + 2)])
o1 = TestObjectFactory()
@@ -2032,7 +2032,7 @@ class ListTestCase(unittest.TestCase):
def test_list_override(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.List([1])
o = TestObjectFactory(one__0=2)
@@ -2041,7 +2041,7 @@ class ListTestCase(unittest.TestCase):
def test_list_extra_key(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = factory.List([1])
o = TestObjectFactory(one__1=2)
@@ -2050,7 +2050,7 @@ class ListTestCase(unittest.TestCase):
def test_list_merged_fields(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
two = 13
one = factory.List([
1,
@@ -2064,7 +2064,7 @@ class ListTestCase(unittest.TestCase):
def test_nested_lists(self):
class TestObjectFactory(factory.Factory):
class Meta:
- target = TestObject
+ model = TestObject
one = 1
two = factory.List([