DB – Do NOT do it! • Using fixtures – Not very handy • Using the ORM way to create data – It's ok but it can be long, repetitive and increase the lines of code in unittests • Or ...
and create() ) • Powerful helpers for common cases (sequences, sub-factories, reverse dependencies, circular factories, ...) • Support for various ORMs (currently Django, Mogo, MongoEngine, SQLAlchemy) • Python >= 2.6 and PyPy are supported
saved customer = CustomerFactory.build() # Returns a saved Customer instance customer = CustomerFactory.create() # Returns a dict of attributes that can be used to # build a Customer instance attributes = CustomerFactory.attributes()