pytest-dev / pytest-dev/pytest-factoryboy

Alternative for `register`

Open
#193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
400
Forks
44
Avg merge
6h 34m
Merged PRs (30d)
1

Description

We may want to provide an alternative to the register(...) function to inject fixtures in the current module.

I considered having a special variable, like "bdd_fixtures", that the user can declare in the module. We can then check at collection time if a module has this variable and inject the fixtures.

Example:

factoryboy_fixtures = (
    register("foo", FooFactory),
    ...
)

The reason for this is that it's not nice to have to do a from .my_fixtures import * for a user when fixtures are defined across multiple modules and have to be imported in the main conftest.py.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing register(...) implementation and the collection-time fixture injection logic. Compare how fixtures are imported from multiple modules, then define the behavior for discovering a module-level factoryboy_fixtures value. Done means modules can declare that value to inject fixtures without importing register(...) calls into conftest.py, while the existing approach remains understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.