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

Force generation to use strategy defined within the factories meta #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest_factoryboy/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Factory(factory_class):
if argname in request._fixturedef.argnames:
kwargs[key] = evaluate(request, request.getfixturevalue(argname))

strategy = factory.enums.CREATE_STRATEGY
strategy = Factory._meta.strategy
builder = factory.builder.StepBuilder(Factory._meta, kwargs, strategy)
step = factory.builder.BuildStep(builder=builder, sequence=Factory._meta.next_sequence())

Expand Down
4 changes: 3 additions & 1 deletion pytest_factoryboy/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""pytest-factoryboy plugin."""

from collections import defaultdict
from factory import enums
import pytest


Expand Down Expand Up @@ -72,7 +73,8 @@ def after_postgeneration(self, request):
results = self.results.pop(model)
obj = request.getfixturevalue(model)
factory = self.model_factories[model]
factory._after_postgeneration(obj, create=True, results=results)
create = factory._meta.strategy == enums.CREATE_STRATEGY
factory._after_postgeneration(obj, create=create, results=results)

def evaluate(self, request):
"""Finalize, run deferred post-generation actions, etc."""
Expand Down