We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'd like to override the sequence counter.
My first attempt:
# models.py from django.db import models class Foo(models.Model): a = models.IntegerField() b = models.IntegerField() # factories.py from factory import DjangoModelFactory, Sequence from .models import Foo class FooFactory(DjangoModelFactory): class Meta: model = Foo a = Sequence(lambda x: x) b = Sequence(lambda x: x) # test_one.py from pytest_factoryboy import register from .factories import FooFactory register(FooFactory, __sequence=8) @pytest.fixture def foo__sequence(): return 9 @pytest.fixture def foo____sequence(): return 10 def test_1(db, foo): assert foo.a in (8, 9, 10)
I ended up with the following workaround:
# factories.py from factory import DjangoModelFactory, Sequence, SelfAttribute from .models import Foo class FooFactory(DjangoModelFactory): class Meta: model = Foo exclude = ('i',) i = Sequence(lambda x: x) a = SelfAttribute('i') b = SelfAttribute('i') # test_one.py from pytest_factoryboy import register from .factories import FooFactory register(FooFactory, i=8) @pytest.fixture def foo__i(): return 9 def test_1(db, foo): assert foo.a in (8, 9) assert foo.b in (8, 9)
Either register or foo__i work, no need for both of course.
register
foo__i
The workaround is simple, so it may suffice to just note the workaround in the docs for now. Or if I've missed something, please let me know.
Thanks for the nice plugin.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'd like to override the sequence counter.
My first attempt:
I ended up with the following workaround:
Either
register
orfoo__i
work, no need for both of course.The workaround is simple, so it may suffice to just note the workaround in the docs for now. Or if I've missed something, please let me know.
Thanks for the nice plugin.
The text was updated successfully, but these errors were encountered: