summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2011-09-05 21:24:45 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2011-09-05 21:24:45 +0200
commit0d97937d994d4ec11f77661985be971a61daa6e3 (patch)
treeeac60636282d7ce58d89be34a10da7972f455884 /factory
parent6983f7fcbb9bad0ea825fb3de8682f178fab5647 (diff)
downloadfactory-boy-0d97937d994d4ec11f77661985be971a61daa6e3.tar
factory-boy-0d97937d994d4ec11f77661985be971a61daa6e3.tar.gz
Update docstrings.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py29
-rw-r--r--factory/containers.py6
-rw-r--r--factory/declarations.py8
3 files changed, 22 insertions, 21 deletions
diff --git a/factory/base.py b/factory/base.py
index 858f20e..380e015 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -50,10 +50,10 @@ def get_factory_base(bases):
class BaseFactoryMetaClass(type):
- '''Factory metaclass for handling ordered declarations.'''
+ """Factory metaclass for handling ordered declarations."""
def __call__(cls, **kwargs):
- '''Create an associated class instance using the default build strategy. Never create a Factory instance.'''
+ """Create an associated class instance using the default build strategy. Never create a Factory instance."""
if cls.default_strategy == BUILD_STRATEGY:
return cls.build(**kwargs)
@@ -65,8 +65,8 @@ class BaseFactoryMetaClass(type):
raise BaseFactory.UnknownStrategy('Unknown default_strategy: {0}'.format(cls.default_strategy))
def __new__(cls, class_name, bases, attrs, extra_attrs={}):
- '''Record attributes (unordered declarations) and ordered declarations for construction of
- an associated class instance at a later time.'''
+ """Record attributes (unordered declarations) and ordered declarations for construction of
+ an associated class instance at a later time."""
parent_factories = get_factory_base(bases)
if not parent_factories or attrs.get('ABSTRACT_FACTORY', False):
@@ -85,18 +85,19 @@ class BaseFactoryMetaClass(type):
return super(BaseFactoryMetaClass, cls).__new__(cls, class_name, bases, non_factory_attrs)
+
class FactoryMetaClass(BaseFactoryMetaClass):
- '''Factory metaclass for handling class association and ordered declarations.'''
+ """Factory metaclass for handling class association and ordered declarations."""
- ERROR_MESSAGE = '''Could not determine what class this factory is for.
- Use the {0} attribute to specify a class.'''
- ERROR_MESSAGE_AUTODISCOVERY = ERROR_MESSAGE + '''
+ ERROR_MESSAGE = """Could not determine what class this factory is for.
+ Use the {0} attribute to specify a class."""
+ ERROR_MESSAGE_AUTODISCOVERY = ERROR_MESSAGE + """
Also, autodiscovery failed using the name '{1}'
- based on the Factory name '{2}' in {3}.'''
+ based on the Factory name '{2}' in {3}."""
def __new__(cls, class_name, bases, attrs):
- '''Determine the associated class based on the factory class name. Record the associated class
- for construction of an associated class instance at a later time.'''
+ """Determine the associated class based on the factory class name. Record the associated class
+ for construction of an associated class instance at a later time."""
parent_factories = get_factory_base(bases)
if not parent_factories or attrs.get('ABSTRACT_FACTORY', False):
@@ -139,7 +140,7 @@ class FactoryMetaClass(BaseFactoryMetaClass):
# Factory base classes
class BaseFactory(object):
- '''Factory base support for sequences, attributes and stubs.'''
+ """Factory base support for sequences, attributes and stubs."""
class UnknownStrategy(RuntimeError): pass
class UnsupportedStrategy(RuntimeError): pass
@@ -203,9 +204,9 @@ class StubFactory(BaseFactory):
default_strategy = STUB_STRATEGY
class Factory(BaseFactory):
- '''Factory base with build and create support.
+ """Factory base with build and create support.
- This class has the ability to support multiple ORMs by using custom creation functions.'''
+ This class has the ability to support multiple ORMs by using custom creation functions."""
__metaclass__ = FactoryMetaClass
diff --git a/factory/containers.py b/factory/containers.py
index be61641..b46a19f 100644
--- a/factory/containers.py
+++ b/factory/containers.py
@@ -24,9 +24,9 @@ from declarations import OrderedDeclaration, SubFactory
ATTR_SPLITTER = '__'
class ObjectParamsWrapper(object):
- '''A generic container that allows for getting but not setting of attributes.
+ """A generic container that allows for getting but not setting of attributes.
- Attributes are set at initialization time.'''
+ Attributes are set at initialization time."""
initialized = False
@@ -168,6 +168,6 @@ class DeclarationsHolder(object):
return attributes
class StubObject(object):
- '''A generic container.'''
+ """A generic container."""
pass
diff --git a/factory/declarations.py b/factory/declarations.py
index b930b4d..898493c 100644
--- a/factory/declarations.py
+++ b/factory/declarations.py
@@ -39,21 +39,21 @@ class GlobalCounter(object):
class OrderedDeclaration(object):
- '''A factory declaration.
+ """A factory declaration.
Ordered declarations keep track of the order in which they're defined so that later declarations
- can refer to attributes created by earlier declarations when the declarations are evaluated.'''
+ can refer to attributes created by earlier declarations when the declarations are evaluated."""
_next_order = 0
def __init__(self):
self.order = GlobalCounter.step()
def evaluate(self, factory, attributes):
- '''Evaluate this declaration.
+ """Evaluate this declaration.
Args:
factory: The factory this declaration was defined in.
- attributes: The attributes created by the unordered and ordered declarations up to this point.'''
+ attributes: The attributes created by the unordered and ordered declarations up to this point."""
raise NotImplementedError('This is an abstract method')