Monkeypatch FactoryOptions for backwards compatibility #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #47
factory_boy 2.9.0+ renames the 'postgen_declarations' parameter in FactoryOptions to 'post_declarations', and uses a DeclarationSet instead of a dict to handle the declarations.
This pull request monkey patches the newer FactoryOptions instances to include a 'postgen_declarations' property, which should behave similarly enough to the attribute in the older factory_boy versions.
pytest_factory's own unit tests don't pass with the branch as-is, but exposing the 'postgen_declarations' allowed the test suite for my Django web application to work again. factory_boy has gone through a lot of refactoring, so I doubt a complete fix would be nearly as simple.
The solution still feels quite hacky to me, so I'm up for a better solution if one is created. One option is dropping support for older factory_boy versions, though that would involve fixing the library to work with the newer factory_boy.
This change is