Skip to content

Commit

Permalink
fix PostGenerationContext import path (#109)
Browse files Browse the repository at this point in the history
* fix PostGenerationContext import path

* add entry about factory_boy >= 3.2.0 support
  • Loading branch information
skarzi committed Dec 30, 2020
1 parent 5298926 commit 5540be6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased
- Add python 3.9 and 3.10 to the CI test matrix.
- Add pytest 6 to the CI test matrix.
- Drop support for pytest < 4.6.
- Add support for factory_boy >= 3.2.0


2.0.3
Expand Down
4 changes: 4 additions & 0 deletions pytest_factoryboy/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
try:
from factory.declarations import PostGenerationContext
except ImportError: # factory_boy < 3.2.0
from factory.builder import PostGenerationContext
4 changes: 3 additions & 1 deletion pytest_factoryboy/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from inspect import getmodule, signature

from pytest_factoryboy.compat import PostGenerationContext

SEPARATOR = "__"


Expand Down Expand Up @@ -238,7 +240,7 @@ class Factory(factory_class):
else:
extra[k] = v

postgen_context = factory.builder.PostGenerationContext(
postgen_context = PostGenerationContext(
value_provided=True,
value=evaluate(request, request.getfixturevalue(argname)),
extra=extra,
Expand Down

0 comments on commit 5540be6

Please sign in to comment.