Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monkeypatch FactoryOptions for backwards compatibility #54

Closed
wants to merge 3 commits into from

Conversation

Matoking
Copy link

@Matoking Matoking commented Oct 6, 2017

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 Reviewable

@olegpidsadnyi
Copy link
Contributor

I'll work on the major release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors with factory_boy master: 'FactoryOptions' object has no attribute 'postgen_declarations'
2 participants