Toffee: Test Object Fixture Factories - easy creation of data fixtures for tests
Toffee: Test Object Factory Fixtures
Toffee creates factories for your model fixtures:
from toffee import Fixture, Factory product_factory = Factory(Product, id=Seq()) class MyFixture(Fixture): product_1 = product_factory(desc='cuddly toy') product_2 = product_factory(desc='toy tractor') user = Factory(User, username='fred') order = Factory(Order, user=user, products=[product_1, product_2]) def test_product_search(): with MyFixture() as f: assert f.product_1 in search_products('toy') assert f.product_2 in search_products('toy')
Toffee is similar in scope to factory_boy. The differences that prompted me to write a new library are:
- Toffee promotes working with on fixtures as groups of objects to be created and destroyed as a unit, rather than individual factories
- Explicit support for setup/teardown of fixtures
Toffee is developed and maintained by Olly Cope.
1.0.0 (released 2019-05-15)
- Added support for Python 3.7
- Dropped support for Python 2.x
0.2.1 (released 2017-10-04)
- Added support for Python 3.5, 3.6. Dropped support for Python 3.3, 3.4
- Dropped support for using setattr to configure subobjects. Use the double underscore convention instead.
- Attribute/item setting on factory objects now results in the same operation being carried out on the generated object. This is useful for creating circular references between factory objects.
- Lists of factory objects are now supported, making it easier to manage large numbers of test objects.
- Factories now can take a partial flag. This stops the factory from producing a top-level named object, while still allowing it to be used for the basis of other factories.
- Added support for Python 3.4.
- Dropped support for Python 3.2.
- Tests that delete fixture objects before teardown is called no longer cause SQLAlchemy to invalidate the transaction (and thus potentially cause later tests to fail unexpectedly).
- Added a scope argument to Seq(), that determines whether the sequence counter is reset at the start of each fixture set up or only once, at the start of the test run.
- Licensing: toffee is now licensed under the Apache License, Version 2.0
- Bugfix: Fixed exception in LazyRecorderFactory.destroy_object during fixture teardown
- Added toffee.TestWithFixture
- The data mapper factories (SQLAlchemy and Storm) support querying for existing objects in fixtures
- Added experimental SQLAlchemy support
- Made setting factoryoptions more flexible. It’s now possible to change the default flush/commit behavior of StormFactory per fixture class and or at setup time when using the context manager syntax.
- Bugfix: StormFactory did not flush/commit the store on fixture teardown teardown, meaning the store would not be left clean for subsequent operations
- initial release
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size toffee-1.0.0-py3-none-any.whl (12.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size toffee-1.0.0.tar.gz (15.2 kB)||File type Source||Python version None||Upload date||Hashes View hashes|