Last active
December 27, 2015 02:39
-
-
Save tcmb/7253456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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