From d72e7e0425ce7a68d319c21613acf4ad3508f092 Mon Sep 17 00:00:00 2001 From: Nekmo Date: Tue, 11 Jun 2019 01:00:22 +0200 Subject: [PATCH] Replaced AutoFixture with Factory Boy. --- admin_auto_tests/test_model.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/admin_auto_tests/test_model.py b/admin_auto_tests/test_model.py index 6a507e4..acf77e6 100644 --- a/admin_auto_tests/test_model.py +++ b/admin_auto_tests/test_model.py @@ -1,6 +1,6 @@ from unittest import SkipTest -from autofixture import AutoFixture +import factory from django.contrib.auth import get_user_model try: from django.core.urlresolvers import reverse @@ -13,6 +13,14 @@ from admin_auto_tests.utils import test_base_class +def create_factory(model_class, **kwargs): + class Factory(factory.django.DjangoModelFactory): + class Meta: + model = model_class + + return Factory + + class AdminTestMixIn(object): field_values = None model = None @@ -20,8 +28,8 @@ class AdminTestMixIn(object): def create(self, commit=True, model=None, follow_fk=True, generate_fk=True, field_values=None): model = model or self.model field_values = field_values or self.field_values - instance = AutoFixture(model, follow_fk=follow_fk, generate_fk=generate_fk, - field_values=field_values).create_one(commit) + instance = create_factory(model, follow_fk=follow_fk, generate_fk=generate_fk, + field_values=field_values)() return instance def create_user(self, is_staff=False, is_superuser=False, is_active=True):