aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/orms.rst9
-rw-r--r--docs/reference.rst29
-rw-r--r--factory/alchemy.py5
-rw-r--r--factory/base.py26
-rw-r--r--factory/declarations.py9
-rw-r--r--factory/django.py5
-rw-r--r--factory/helpers.py1
-rw-r--r--tests/__init__.py1
-rw-r--r--tests/test_declarations.py15
-rw-r--r--tests/test_deprecation.py49
-rw-r--r--tests/test_using.py2
11 files changed, 1 insertions, 150 deletions
diff --git a/docs/orms.rst b/docs/orms.rst
index 88d49e9..e32eafa 100644
--- a/docs/orms.rst
+++ b/docs/orms.rst
@@ -39,11 +39,6 @@ All factories for a Django :class:`~django.db.models.Model` should use the
attributes, the base object will be :meth:`saved <django.db.models.Model.save>`
once all post-generation hooks have run.
- .. attribute:: FACTORY_DJANGO_GET_OR_CREATE
-
- .. deprecated:: 2.4.0
- See :attr:`DjangoOptions.django_get_or_create`.
-
.. class:: DjangoOptions(factory.base.FactoryOptions)
@@ -284,10 +279,6 @@ To work, this class needs an `SQLAlchemy`_ session object affected to the :attr:
* :func:`~factory.Factory.create()` uses :meth:`sqlalchemy.orm.session.Session.add`
- .. attribute:: FACTORY_SESSION
-
- .. deprecated:: 2.4.0
- See :attr:`~SQLAlchemyOptions.sqlalchemy_session`.
.. class:: SQLAlchemyOptions(factory.base.FactoryOptions)
diff --git a/docs/reference.rst b/docs/reference.rst
index b0dda50..5eea62c 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -115,35 +115,6 @@ The :class:`Factory` class
.. class:: Factory
- .. note:: In previous versions, the fields of :class:`class Meta <factory.FactoryOptions>` were
- defined as class attributes on :class:`Factory`. This is now deprecated and will be removed
- in 2.5.0.
-
- .. attribute:: FACTORY_FOR
-
- .. deprecated:: 2.4.0
- See :attr:`FactoryOptions.model`.
-
- .. attribute:: ABSTRACT_FACTORY
-
- .. deprecated:: 2.4.0
- See :attr:`FactoryOptions.abstract`.
-
- .. attribute:: FACTORY_ARG_PARAMETERS
-
- .. deprecated:: 2.4.0
- See :attr:`FactoryOptions.inline_args`.
-
- .. attribute:: FACTORY_HIDDEN_ARGS
-
- .. deprecated:: 2.4.0
- See :attr:`FactoryOptions.exclude`.
-
- .. attribute:: FACTORY_STRATEGY
-
- .. deprecated:: 2.4.0
- See :attr:`FactoryOptions.strategy`.
-
**Class-level attributes:**
diff --git a/factory/alchemy.py b/factory/alchemy.py
index 2cd28bb..6408393 100644
--- a/factory/alchemy.py
+++ b/factory/alchemy.py
@@ -38,11 +38,6 @@ class SQLAlchemyModelFactory(base.Factory):
class Meta:
abstract = True
- _OLDSTYLE_ATTRIBUTES = base.Factory._OLDSTYLE_ATTRIBUTES.copy()
- _OLDSTYLE_ATTRIBUTES.update({
- 'FACTORY_SESSION': 'sqlalchemy_session',
- })
-
@classmethod
def _create(cls, model_class, *args, **kwargs):
"""Create an instance of the model, and save it to the database."""
diff --git a/factory/base.py b/factory/base.py
index 9e07899..efff976 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -21,7 +21,6 @@
# THE SOFTWARE.
import logging
-import warnings
from . import containers
from . import declarations
@@ -109,23 +108,6 @@ class FactoryMetaClass(type):
attrs_meta = attrs.pop('Meta', None)
- oldstyle_attrs = {}
- converted_attrs = {}
- for old_name, new_name in base_factory._OLDSTYLE_ATTRIBUTES.items():
- if old_name in attrs:
- oldstyle_attrs[old_name] = new_name
- converted_attrs[new_name] = attrs.pop(old_name)
- if oldstyle_attrs:
- warnings.warn(
- "Declaring any of %s at class-level is deprecated"
- " and will be removed in the future. Please set them"
- " as %s attributes of a 'class Meta' attribute." % (
- ', '.join(oldstyle_attrs.keys()),
- ', '.join(oldstyle_attrs.values()),
- ),
- PendingDeprecationWarning, 2)
- attrs_meta = type('Meta', (object,), converted_attrs)
-
base_meta = resolve_attribute('_meta', bases)
options_class = resolve_attribute('_options_class', bases, FactoryOptions)
@@ -322,14 +304,6 @@ class BaseFactory(object):
_meta = FactoryOptions()
- _OLDSTYLE_ATTRIBUTES = {
- 'FACTORY_FOR': 'model',
- 'ABSTRACT_FACTORY': 'abstract',
- 'FACTORY_STRATEGY': 'strategy',
- 'FACTORY_ARG_PARAMETERS': 'inline_args',
- 'FACTORY_HIDDEN_ARGS': 'exclude',
- }
-
# ID to use for the next 'declarations.Sequence' attribute.
_counter = None
diff --git a/factory/declarations.py b/factory/declarations.py
index 5e7e734..f6f5846 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -22,7 +22,6 @@
import itertools
-import warnings
import logging
from . import compat
@@ -502,14 +501,6 @@ class RelatedFactory(PostGenerationDeclaration):
def __init__(self, factory, factory_related_name='', **defaults):
super(RelatedFactory, self).__init__()
- if factory_related_name == '' and defaults.get('name') is not None:
- warnings.warn(
- "Usage of RelatedFactory(SomeFactory, name='foo') is deprecated"
- " and will be removed in the future. Please use the"
- " RelatedFactory(SomeFactory, 'foo') or"
- " RelatedFactory(SomeFactory, factory_related_name='foo')"
- " syntax instead", PendingDeprecationWarning, 2)
- factory_related_name = defaults.pop('name')
self.name = factory_related_name
self.defaults = defaults
diff --git a/factory/django.py b/factory/django.py
index c58a6e2..7050366 100644
--- a/factory/django.py
+++ b/factory/django.py
@@ -84,11 +84,6 @@ class DjangoModelFactory(base.Factory):
class Meta:
abstract = True # Optional, but explicit.
- _OLDSTYLE_ATTRIBUTES = base.Factory._OLDSTYLE_ATTRIBUTES.copy()
- _OLDSTYLE_ATTRIBUTES.update({
- 'FACTORY_DJANGO_GET_OR_CREATE': 'django_get_or_create',
- })
-
@classmethod
def _load_model_class(cls, definition):
diff --git a/factory/helpers.py b/factory/helpers.py
index 19431df..b9cef6e 100644
--- a/factory/helpers.py
+++ b/factory/helpers.py
@@ -28,7 +28,6 @@ import logging
from . import base
from . import declarations
-from . import django
@contextlib.contextmanager
diff --git a/tests/__init__.py b/tests/__init__.py
index 855beea..5b6fc55 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -4,7 +4,6 @@
from .test_base import *
from .test_containers import *
from .test_declarations import *
-from .test_deprecation import *
from .test_django import *
from .test_fuzzy import *
from .test_helpers import *
diff --git a/tests/test_declarations.py b/tests/test_declarations.py
index 86bc8b5..18a4cd4 100644
--- a/tests/test_declarations.py
+++ b/tests/test_declarations.py
@@ -22,7 +22,6 @@
import datetime
import itertools
-import warnings
from factory import declarations
from factory import helpers
@@ -207,20 +206,6 @@ class FactoryWrapperTestCase(unittest.TestCase):
datetime.date = orig_date
-class RelatedFactoryTestCase(unittest.TestCase):
-
- def test_deprecate_name(self):
- with warnings.catch_warnings(record=True) as w:
-
- warnings.simplefilter('always')
- f = declarations.RelatedFactory('datetime.date', name='blah')
-
- self.assertEqual('blah', f.name)
- self.assertEqual(1, len(w))
- self.assertIn('RelatedFactory', str(w[0].message))
- self.assertIn('factory_related_name', str(w[0].message))
-
-
class PostGenerationMethodCallTestCase(unittest.TestCase):
def setUp(self):
self.obj = mock.MagicMock()
diff --git a/tests/test_deprecation.py b/tests/test_deprecation.py
deleted file mode 100644
index a07cbf3..0000000
--- a/tests/test_deprecation.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2010 Mark Sandstrom
-# Copyright (c) 2011-2013 Raphaƫl Barrois
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-
-"""Tests for deprecated features."""
-
-import warnings
-
-import factory
-
-from .compat import mock, unittest
-from . import tools
-
-
-class DeprecationTests(unittest.TestCase):
- def test_factory_for(self):
- class Foo(object):
- pass
-
- with warnings.catch_warnings(record=True) as w:
- warnings.simplefilter('always')
- class FooFactory(factory.Factory):
- FACTORY_FOR = Foo
-
- self.assertEqual(1, len(w))
- warning = w[0]
- # Message is indeed related to the current file
- # This is to ensure error messages are readable by end users.
- self.assertIn(warning.filename, __file__)
- self.assertIn('FACTORY_FOR', str(warning.message))
- self.assertIn('model', str(warning.message))
diff --git a/tests/test_using.py b/tests/test_using.py
index 8aba8b6..7318f2e 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -1798,7 +1798,7 @@ class PostGenerationTestCase(unittest.TestCase):
model = TestObject
one = 3
two = 2
- three = factory.RelatedFactory(TestRelatedObjectFactory, name='obj')
+ three = factory.RelatedFactory(TestRelatedObjectFactory, 'obj')
obj = TestObjectFactory.build()
# Normal fields