Accepting request 942993 from devel:languages:python

- Add missing BR typing_extensions
- Add tests-skip-django-py36.patch -- no Django 4 for python36

OBS-URL: https://build.opensuse.org/request/show/942993
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-factory_boy?expand=0&rev=16
This commit is contained in:
Dominique Leuenberger 2021-12-30 14:55:20 +00:00 committed by Git OBS Bridge
commit d21f515826
3 changed files with 107 additions and 3 deletions

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Dec 28 22:54:39 UTC 2021 - Matej Cepl <mcepl@suse.com>
- Add missing BR typing_extensions
-------------------------------------------------------------------
Mon Dec 27 18:24:13 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Add tests-skip-django-py36.patch -- no Django 4 for python36
-------------------------------------------------------------------
Sun May 16 13:01:17 UTC 2021 - Ben Greiner <code@bnavigator.de>

View File

@ -25,13 +25,15 @@ Summary: Python test fixtures
License: MIT
URL: https://github.com/rbarrois/factory_boy
Source: https://files.pythonhosted.org/packages/source/f/factory_boy/factory_boy-%{version}.tar.gz
BuildRequires: %{python_module Django}
# PATCH-FEATURE-OPENSUSE tests-skip-django-py36.patch -- don't test django on python36: no python36-Django 4, code@bnavigator.de
Patch0: tests-skip-django-py36.patch
BuildRequires: %{python_module Faker >= 0.7.0}
BuildRequires: %{python_module Pillow}
BuildRequires: %{python_module setuptools >= 0.8}
BuildRequires: %{pythons}
BuildRequires: %{python_module typing_extensions}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: %{python_module Django if (%python-base without python36-base)}
Requires: python-Faker >= 0.7.0
BuildArch: noarch
%python_subpackages
@ -40,7 +42,7 @@ BuildArch: noarch
A test fixtures replacement based on thoughtbot's factory_girl for Ruby.
%prep
%setup -q -n factory_boy-%{version}
%autosetup -p1 -n factory_boy-%{version}
# needs running mongo
rm tests/test_mongoengine.py
sed -i -e '/test_mongoengine/d' tests/__init__.py

View File

@ -0,0 +1,92 @@
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):