pytest-dev / pytest-dev/pytest-factoryboy

RelatedFactory is not working inside fixtures

Open
#97 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

How to reproduce (just one step):

to test https://github.com/pytest-dev/pytest-factoryboy/blob/master/tests/test_circular.py

add

@pytest.fixture(autouse=True)
def autouse_fixture_check(author):
    assert author.books

Output:

E
test setup failed
author = <test.Author object at 0x10a426dd0>

    @pytest.fixture(autouse=True)
    def autouse_fixture_check(author):
>       assert author.books
E       assert []
E        +  where [] = <test.Author object at 0x10a426dd0>.books

test.py:53: AssertionError

Broken versions: >= 2.0.1, <= 2.0.3 (current)
Last version that works: 1.3.2

Example setup for working version:

pip install pytest==3.10.1 factory-boy==2.8.1 pytest-factoryboy==1.3.2

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 reproducing the issue in tests/test_circular.py with the added autouse fixture and the listed pytest, factory-boy, and pytest-factoryboy versions. Trace how RelatedFactory and fixtures are set up, then add a regression check showing that author.books is populated and run the circular fixture tests.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.