summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/changelog.rst1
-rw-r--r--docs/reference.rst13
-rw-r--r--factory/__init__.py1
-rw-r--r--factory/declarations.py14
-rw-r--r--tests/test_declarations.py44
5 files changed, 1 insertions, 72 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 88107a4..518ab9e 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -16,6 +16,7 @@ ChangeLog
- Remove associated class discovery
- Remove :class:`~factory.InfiniteIterator` and :func:`~factory.infinite_iterator`
+ - Remove :class:`~factory.CircularSubFactory`
- Stop defaulting to Django's ``Foo.objects.create()`` when "creating" instances
- Remove STRATEGY_*
- Remove :meth:`~factory.Factory.set_building_function` / :meth:`~factory.Factory.set_creation_function`
diff --git a/docs/reference.rst b/docs/reference.rst
index 27e2e14..955d3c5 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -657,19 +657,6 @@ Obviously, such circular relationships require careful handling of loops:
<john (group: MyGroup)>
-.. class:: CircularSubFactory(module_name, symbol_name, **kwargs)
-
- .. OHAI_VIM**
-
- Lazily imports ``module_name.symbol_name`` at the first call.
-
-.. deprecated:: 1.3.0
- Merged into :class:`SubFactory`; will be removed in 2.0.0.
-
- Replace ``factory.CircularSubFactory('some.module', 'Symbol', **kwargs)``
- with ``factory.SubFactory('some.module.Symbol', **kwargs)``
-
-
SelfAttribute
"""""""""""""
diff --git a/factory/__init__.py b/factory/__init__.py
index 4b4857c..adcf9c9 100644
--- a/factory/__init__.py
+++ b/factory/__init__.py
@@ -55,7 +55,6 @@ from .declarations import (
SelfAttribute,
ContainerAttribute,
SubFactory,
- CircularSubFactory,
PostGeneration,
PostGenerationMethodCall,
RelatedFactory,
diff --git a/factory/declarations.py b/factory/declarations.py
index 1f64038..b3c9d6a 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -325,20 +325,6 @@ class SubFactory(ParameteredAttribute):
return subfactory.build(**params)
-class CircularSubFactory(SubFactory):
- """Use to solve circular dependencies issues."""
- def __init__(self, module_name, factory_name, **kwargs):
- factory = '%s.%s' % (module_name, factory_name)
- warnings.warn(
- "factory.CircularSubFactory is deprecated and will be removed in "
- "the future. "
- "Please replace factory.CircularSubFactory('module', 'symbol') "
- "with factory.SubFactory('module.symbol').",
- PendingDeprecationWarning, 2)
-
- super(CircularSubFactory, self).__init__(factory, **kwargs)
-
-
class PostGenerationDeclaration(object):
"""Declarations to be called once the target object has been generated.
diff --git a/tests/test_declarations.py b/tests/test_declarations.py
index 2e527af..ceadafa 100644
--- a/tests/test_declarations.py
+++ b/tests/test_declarations.py
@@ -363,49 +363,5 @@ class PostGenerationMethodCallTestCase(unittest.TestCase):
-class CircularSubFactoryTestCase(unittest.TestCase):
-
- def test_circularsubfactory_deprecated(self):
- with warnings.catch_warnings(record=True) as w:
- __warningregistry__.clear()
-
- warnings.simplefilter('always')
- declarations.CircularSubFactory('datetime', 'date')
-
- self.assertEqual(1, len(w))
- self.assertIn('CircularSubFactory', str(w[0].message))
- self.assertIn('deprecated', str(w[0].message))
-
- @tools.disable_warnings
- def test_lazyness(self):
- f = declarations.CircularSubFactory('factory.declarations', 'Sequence', x=3)
- self.assertEqual(None, f.factory)
-
- self.assertEqual({'x': 3}, f.defaults)
-
- factory_class = f.get_factory()
- self.assertEqual(declarations.Sequence, factory_class)
-
- @tools.disable_warnings
- def test_cache(self):
- orig_date = datetime.date
- f = declarations.CircularSubFactory('datetime', 'date')
- self.assertEqual(None, f.factory)
-
- factory_class = f.get_factory()
- self.assertEqual(orig_date, factory_class)
-
- try:
- # Modify original value
- datetime.date = None
- # Repeat import
- factory_class = f.get_factory()
- self.assertEqual(orig_date, factory_class)
-
- finally:
- # IMPORTANT: restore attribute.
- datetime.date = orig_date
-
-
if __name__ == '__main__':
unittest.main()