pytest-dev / pytest-dev/pytest-factoryboy
Exposing a fixture for deferred factory evaluation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 400
- Forks
- 44
- Avg merge
- 6h 34m
- Merged PRs (30d)
- 1
Description
It'd be nice to be able to expose a fixture (maybe the factory fixture?) that can be invoked in the test invocation.
Here's a few use cases:
- creating the object when using a decorator, e.g.
factory.django.mute_signals(signals.post_save) - create the object imperatively in the test body, for example if you use
@pytest.mark.django_db(transactional=True), and you need to create your object within adjango.db.transaction.atomic()context manager.
class Book:
name: str
class BookFactory(Factory):
name = "foo"
@pytest.mark.parametrize("book__name", ["bar"])
def test_book_initialise_later(book_factory):
book = book_factory()
assert book.name == bar
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 tracing the pytest fixture integration and the existing factory fixture behavior, then use the book_factory example and its pytest.mark.parametrize case as the expected entry point. The work is done when a factory can be invoked inside the test body and supports deferred creation for decorator and transactional django.db.transaction.atomic() use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100