Skip to content

Instantly share code, notes, and snippets.

@tcmb
Last active December 27, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcmb/7253456 to your computer and use it in GitHub Desktop.
Save tcmb/7253456 to your computer and use it in GitHub Desktop.
from factory.alchemy import SQLAlchemyModelFactory
from factory import Sequence
from mymodels import SomeClass, OtherClass
class ItemFactory(SQLAlchemyModelFactory):
ABSTRACT_FACTORY = True
shared_counter = Sequence(lambda n: '{0}'.format(n))
ItemFactory.reset_sequence(value=100, force=True)
class SomeItem(ItemFactory):
FACTORY_FOR = SomeClass
some_field = 'hello'
#shared_counter should be inherited
class OtherItem(ItemFactory):
FACTORY_FOR = OtherClass
other_field = 'world'
#shared_counter should be inherited
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment