We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
factory.Maybe
It would be great if pytest-factoryboy could better handle factory.Maybe, so that it can reflect how factoryboy handles it.
from __future__ import annotations import pytest from factory import * from pytest_factoryboy import register from dataclasses import * @dataclass class Company: name: str @dataclass class User: is_staff: bool company: Company | None @register class CompanyFactory(Factory): class Meta: model = Company name = "foo" @register class UserFactory(Factory): class Meta: model = User is_staff = False company = Maybe("is_staff", yes_declaration=None, no_declaration=SubFactory(CompanyFactory)) @pytest.mark.parametrize("user__is_staff", [False]) def test_staff_user_has_no_company_by_default(user): assert user.company is None @pytest.mark.parametrize("user__is_staff", [False]) def test_normal_user_has_company_by_default(user, company): assert user.company is company
This test module should succeed, but it doesn't. (I don't have a stack trace with me at the moment)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It would be great if pytest-factoryboy could better handle
factory.Maybe
, so that it can reflect how factoryboy handles it.This test module should succeed, but it doesn't. (I don't have a stack trace with me at the moment)
The text was updated successfully, but these errors were encountered: