-
Notifications
You must be signed in to change notification settings - Fork 408
Open
Labels
Description
Description
Overriding _setup_next_sequence does not work when subclassing DictFactory, but I get it to work for other factories subclassing DjangoModelFactory.
Model / Factory code
import factory
class TestDictFactory(factory.DictFactory):
@classmethod
def _setup_next_sequence(cls) -> int:
return 10
number = factory.Sequence(lambda n: n)Test case
A simple test case where the sequence should start from 10
def test_dict_factory():
test = TestDictFactory()
assert test["number"] == 10Output
=========================================== test session starts ===========================================
platform darwin -- Python 3.10.6, pytest-7.2.0, pluggy-1.0.0
django: ...
rootdir: ...
plugins: Faker-15.1.3, mock-3.10.0, django-4.5.2
collected 61 items / 60 deselected / 1 selected
tests/test_factories.py F [100%]
================================================ FAILURES =================================================
____________________________________________ test_dict_factory ____________________________________________
def test_dict_factory():
test = TestDictFactory()
> assert test["number"] == 10
E assert 0 == 10
tests/test_factories.py:23: AssertionError