-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using factory.List
resolves in unusable fixtures
#67
Comments
I can take this issue as well as #65, because it affected me several times. |
Awesome, @skarzi! I would appreciate a fix. Sadly, I am not familiar with the codebase. |
Currently it's really hard to implement
from dataclasses import dataclass
import factory
from pytest_factoryboy import LazyFixture, register
@dataclass
class Author:
full_name: str
@dataclass
class Book:
author: Author
title: str
class AuthorFactory(factory.Factory):
full_name = factory.Sequence(lambda counter: f'Author {counter}')
class Meta:
model = Author
class LemonySnicketBookFactory(factory.Factory):
author = factory.SubFactory(AuthorFactory, full_name='Lemony Snicket')
title = factory.Sequence(lambda counter: f'A Series of Unfortunate Events {counter}')
class Meta:
model = Book
register(AuthorFactory)
register(LemonySnicketBookFactory, _name='lemony_snicket_book')
def test_subfactory_defaults(lemony_snicket_book):
"""Failure because ``lemony_snicket_book.author.full_name`` is ``'Author 1'``"""
assert lemony_snicket_book.author.full_name == 'Lemony Snicket' So with my current knowledge, I see 2 possible solutions:
I am still not so much into |
@skarzi did you ever get around to a fix? |
Unfortunately not fully :( It would be great to discuss this issue with some more experienced |
I just ran into this issue. Is there any idea on how to solve this? |
Setup
Here are my models:
And my factories:
And finally my test:
Error
This tests fails due to unresolved fixtures:
I guess this happens due to the fact that I am using
factory.List
.Workaround
The text was updated successfully, but these errors were encountered: