Skip to content

Traits not being considered by pytest_factoryboy #220

Open
@youtux

Description

@youtux

Given a factory with traits, pytest_factoryboy should treat them as normal params, and allow them to be parametrized.

MCVE:

@dataclass
class Article:
    comments: int
    views: int

@register
class ArticleFactory(Factory):
    class Meta:
        model = Article

    class Params:
        boring = Trait(
            comments=0,
            views=0,
        )
    comments = 10
    views = 1000

@pytest.mark.parametrize("article__boring", [True])
def test_boring_article(article):
    assert article.comments == 0
    assert article.views == 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions