Skip to content

Commit 5540be6

Browse files
authored
fix PostGenerationContext import path (#109)
* fix PostGenerationContext import path * add entry about factory_boy >= 3.2.0 support
1 parent 5298926 commit 5540be6

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Unreleased
88
- Add python 3.9 and 3.10 to the CI test matrix.
99
- Add pytest 6 to the CI test matrix.
1010
- Drop support for pytest < 4.6.
11+
- Add support for factory_boy >= 3.2.0
1112

1213

1314
2.0.3

pytest_factoryboy/compat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
try:
2+
from factory.declarations import PostGenerationContext
3+
except ImportError: # factory_boy < 3.2.0
4+
from factory.builder import PostGenerationContext

pytest_factoryboy/fixture.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from inspect import getmodule, signature
1313

14+
from pytest_factoryboy.compat import PostGenerationContext
15+
1416
SEPARATOR = "__"
1517

1618

@@ -238,7 +240,7 @@ class Factory(factory_class):
238240
else:
239241
extra[k] = v
240242

241-
postgen_context = factory.builder.PostGenerationContext(
243+
postgen_context = PostGenerationContext(
242244
value_provided=True,
243245
value=evaluate(request, request.getfixturevalue(argname)),
244246
extra=extra,

0 commit comments

Comments
 (0)