pytest-dev / pytest-dev/pytest-factoryboy
`Trait`s not being considered by pytest_factoryboy
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 400
- Forks
- 44
- Avg merge
- 6h 34m
- Merged PRs (30d)
- 1
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MCVE in the issue with pytest and the registered ArticleFactory, then trace how pytest_factoryboy exposes factory parameters to pytest parametrization. Done means article__boring=True is accepted and the resulting Article has comments and views set to 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100