-
Notifications
You must be signed in to change notification settings - Fork 42
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
pytest-factoryboy seems to break factory.django.mute_signals #156
Comments
Nvm again. It seems I forgot to save after switching back to the pytest-factoryboy fixture and assumed the most recent output from pytest-watch was using this fixture. Now pytest-factoryboy just complains
The SubscriptionFactory that SubscriptionNoSignalsFactory inherits from does indeed have a @pytest.mark.parametrize("subscription_no_signals__complete", [False])
@pytest.mark.parametrize("subscription_no_signals__end_date", [days_ago(100)])
@pytest.mark.parametrize("subscription_no_signals__start_date", [days_ago(107)])
@pytest.mark.parametrize("subscription_no_signals__subject__study__start_date", [days_ago(110)])
@pytest.mark.parametrize("subscription_no_signals__subject__study__end_date", [days_ago(-10)])
def test_subscription_too_old_to_mark_complete(subscription_no_signals):
# def test_subscription_too_old_to_mark_complete(old_incomplete_subscription):
subscription = subscription_no_signals
# subscription = old_incomplete_subscription
assert len(mail.outbox) == 1
email = mail.outbox[0]
assert subscription.pk in email.subject
assert subscription.pk in email.body
assert "too old" in email.body I had assumed from the Book/Author example in the docs that I should just pass the name of the registered subfactory fixture (i.e., |
After digging around the code some more I was able to come up with a solution, but I'm leaving this issue open because this looks like a bug. My factory (with debug code; cleaned version in issue description) now looks like this:
I had to override
I thought perhaps |
it seems that there are 2 bugs here. The first one should not be too difficult to fix, I'm not sure about the second one though. I'll try when I have some time. Indeed decorating the Thank you for the bug report. |
hi, is this still an issue? |
Work around
Decorate the class with
mute_signals
, and additionally override_after_postgeneration
and mute signals there too.Problem description
I have the following factory definition using the mute_signals decorator:
NOTE: I also attempted changing the order of the decorators.
And the following unit test:
The test fails with an error as a result of signals being executed when they shouldn't be. The following output is captured from the print statements in
_create
. The empty lists being printed show that at the time of_create
, no signals are connected. The "unique" message ("what the...") ensures this output is not coming from anywhere else.:I also poked around in pdb and found that pytest-factoryboy is saving the model with signals connected.
So it seems mute_signals is broken by pytest-factoryboy. Are there any workarounds?
The text was updated successfully, but these errors were encountered: