1
0
Dirk Mueller 2023-11-11 16:09:00 +00:00 committed by Git OBS Bridge
parent 805f1b42f3
commit 4dde887c74

View File

@ -1,92 +0,0 @@
Index: factory_boy-3.2.0/tests/test_django.py
===================================================================
--- factory_boy-3.2.0.orig/tests/test_django.py
+++ factory_boy-3.2.0/tests/test_django.py
@@ -7,11 +7,14 @@ import os
import unittest
from unittest import mock
-import django
-from django import test as django_test
-from django.conf import settings
-from django.db.models import signals
-from django.test import utils as django_test_utils
+try:
+ import django
+ from django import test as django_test
+ from django.conf import settings
+ from django.db.models import signals
+ from django.test import utils as django_test_utils
+except ImportError:
+ raise unittest.SkipTest("No Django installed")
import factory.django
Index: factory_boy-3.2.0/tests/test_using.py
===================================================================
--- factory_boy-3.2.0.orig/tests/test_using.py
+++ factory_boy-3.2.0/tests/test_using.py
@@ -11,6 +11,7 @@ import unittest
import factory
from factory import errors
+nodjango = not hasattr(factory, 'django')
from . import utils
@@ -141,6 +142,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_create_custom_base(self):
obj = factory.create(FakeModel, foo='bar', FACTORY_CLASS=factory.django.DjangoModelFactory)
self.assertEqual(obj.id, 2)
@@ -156,6 +158,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_create_batch_custom_base(self):
objs = factory.create_batch(
FakeModel,
@@ -196,6 +199,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_generate_create_custom_base(self):
obj = factory.generate(
FakeModel,
@@ -231,6 +235,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_generate_batch_create_custom_base(self):
objs = factory.generate_batch(
FakeModel,
@@ -267,6 +272,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_simple_generate_create_custom_base(self):
obj = factory.simple_generate(FakeModel, True, foo='bar', FACTORY_CLASS=factory.django.DjangoModelFactory)
self.assertEqual(obj.id, 2)
@@ -292,6 +298,7 @@ class SimpleBuildTestCase(unittest.TestC
self.assertEqual(obj.id, None)
self.assertEqual(obj.foo, 'bar')
+ @unittest.skipIf(nodjango, "No Django installed")
def test_simple_generate_batch_create_custom_base(self):
objs = factory.simple_generate_batch(
FakeModel,
@@ -2046,6 +2053,7 @@ class BetterFakeModel:
self.id = None
+@unittest.skipIf(nodjango, "No Django installed")
class DjangoModelFactoryTestCase(unittest.TestCase):
def test_simple(self):
class FakeModelFactory(factory.django.DjangoModelFactory):