From 9bd6e41febd155052d726967a6315e67fd5beb82 Mon Sep 17 00:00:00 2001 From: Daniel Owen Date: Mon, 27 Jan 2020 16:10:16 +0000 Subject: [PATCH 1/2] Update Python and Django versions for compatibility Update package version number from 4.0.0 to 5.0.0. Upgrade Python from 2.6 to 3.6. Upgrade Django from >=1.11,2.0 to >=2.2.9, <3.0. Remove dingus, distlib and django-migration-fixture libraries Delete migration in favour of "fixtures" attribute on TestCase. Upgrade unittest-xml-reporting from >=1.3.2 to >=2.5.2, <3.0 --- .gitignore | 2 ++ requirements.txt | 7 ++----- setup.py | 8 ++++---- test_app/migrations/0001_initial.py | 2 +- test_app/migrations/0002_load_painters.py | 17 ----------------- test_app/tests.py | 4 +++- test_extras/__init__.py | 2 +- test_extras/selenium.py | 2 +- test_extras/testcases.py | 2 +- test_extras/testrunners.py | 2 +- test_extras/webdriverplus.py | 2 +- testsettings.py | 1 - tox.ini | 19 ++++++++----------- 13 files changed, 25 insertions(+), 45 deletions(-) delete mode 100644 test_app/migrations/0002_load_painters.py diff --git a/.gitignore b/.gitignore index d016daf..fb9366f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ MANIFEST build/ .tox/ +*.bak +.idea \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2a10532..edb0c39 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,3 @@ -Django>=1.11,<2.0 +Django>=2.2.9,<3.0 coverage>=3.5.2 -unittest-xml-reporting>=1.3.2 -dingus==0.3.4 -django-migration-fixture==0.1.4 -distlib==0.1.9 +unittest-xml-reporting>=2.5.2 diff --git a/setup.py b/setup.py index 05d4f03..57e7563 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ author = 'Bright Interactive' author_email = 'admin@bright-interactive.co.uk' license = 'BSD' -install_requires = ['Django>=1.11,<=2.0'] +install_requires = ['Django>=2.2.9,<=3.0'] def get_version(package): @@ -53,9 +53,9 @@ def get_package_data(package): if sys.argv[-1] == 'publish': os.system("python setup.py sdist upload") args = {'version': get_version(package)} - print "You probably want to also tag the version now:" - print " git tag -a v%(version)s -m 'version %(version)s'" % args - print " git push --tags" + print("You probably want to also tag the version now:") + print(" git tag -a v%(version)s -m 'version %(version)s'" % args) + print(" git push --tags") sys.exit() diff --git a/test_app/migrations/0001_initial.py b/test_app/migrations/0001_initial.py index 77938ea..2f82bec 100644 --- a/test_app/migrations/0001_initial.py +++ b/test_app/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/test_app/migrations/0002_load_painters.py b/test_app/migrations/0002_load_painters.py deleted file mode 100644 index 1baf191..0000000 --- a/test_app/migrations/0002_load_painters.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django_migration_fixture import fixture -import test_app - - -class Migration(migrations.Migration): - - dependencies = [ - ('test_app', '0001_initial'), - ] - - operations = [ - migrations.RunPython(**fixture(test_app, 'painters.json')), - ] diff --git a/test_app/tests.py b/test_app/tests.py index 21a438d..5557048 100644 --- a/test_app/tests.py +++ b/test_app/tests.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # (c) 2013 Bright Interactive Limited. All rights reserved. # http://www.bright-interactive.com | info@bright-interactive.com from django.test import TestCase, TransactionTestCase @@ -12,6 +12,8 @@ class TestDataPreserving(DataPreservingTransactionTestCaseMixin, TransactionTestCase): + fixtures = ['painters.json'] + def test_migration_data_present_in_test_1(self): painter = Painter.objects.get(id=1) self.assertEqual('Pablo Picasso', painter.name) diff --git a/test_extras/__init__.py b/test_extras/__init__.py index 49fcc5d..7d1e681 100644 --- a/test_extras/__init__.py +++ b/test_extras/__init__.py @@ -2,4 +2,4 @@ # (c) 2012-2015 Bright Interactive Limited. All rights reserved. # http://www.bright-interactive.com | info@bright-interactive.com -__version__ = '4.0.0' +__version__ = '5.0.0' diff --git a/test_extras/selenium.py b/test_extras/selenium.py index 830b7c8..ccd673e 100644 --- a/test_extras/selenium.py +++ b/test_extras/selenium.py @@ -9,7 +9,7 @@ have to depend on selenium. """ -from __future__ import absolute_import + from django.conf import settings from django.contrib.staticfiles.testing import StaticLiveServerTestCase diff --git a/test_extras/testcases.py b/test_extras/testcases.py index 00bfaff..bc4a725 100644 --- a/test_extras/testcases.py +++ b/test_extras/testcases.py @@ -2,7 +2,7 @@ # (c) 2012 Bright Interactive Limited. All rights reserved. # http://www.bright-interactive.com | info@bright-interactive.com -from StringIO import StringIO +from io import StringIO from django.core import management from django.core import serializers from django.core.management import call_command diff --git a/test_extras/testrunners.py b/test_extras/testrunners.py index 70a5b2a..81944a9 100644 --- a/test_extras/testrunners.py +++ b/test_extras/testrunners.py @@ -164,7 +164,7 @@ def get_coverage_files(app_labels, ignore_dirs, ignore_files): for app_label in app_labels: if app_label in settings.INSTALLED_APPS: - module = __import__(app_label, globals(), locals(), [''], -1) + module = __import__(app_label, globals(), locals(), [''], 0) dirname = os.path.dirname(module.__file__) files_for_coverage.extend(get_coverage_files_in_directory(dirname, ignore_dirs, ignore_files)) else: diff --git a/test_extras/webdriverplus.py b/test_extras/webdriverplus.py index d874c00..b54b61e 100644 --- a/test_extras/webdriverplus.py +++ b/test_extras/webdriverplus.py @@ -20,7 +20,7 @@ } """ -from __future__ import absolute_import + from bs4 import BeautifulSoup from django.conf import settings diff --git a/testsettings.py b/testsettings.py index 803e272..5e22154 100644 --- a/testsettings.py +++ b/testsettings.py @@ -12,7 +12,6 @@ 'test_app', 'test_app_no_models', 'dotted.dotted_test_app', - 'django_migration_fixture', ) MIDDLEWARE_CLASSES = ( diff --git a/tox.ini b/tox.ini index dbb4c5e..d56615a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist= - py27-django111, + py36-django229, [testenv] commands= @@ -8,18 +8,15 @@ commands= [base] deps= - coverage==3.5.2 - unittest-xml-reporting==1.3.2 - dingus==0.3.4 - distlib==0.1.9 + coverage==5.0.3 + unittest-xml-reporting==2.5.2 -[django111] +[django229] deps= - Django>=1.11,<2.0a0dev0 + Django>=2.2.9,<3.0a0dev0 {[base]deps} - django-migration-fixture==0.1.4 -[testenv:py27-django111] -basepython=python2.7 +[testenv:py36-django229] +basepython=python3.6 deps= - {[django111]deps} + {[django229]deps} From a38faa8d0799cebd2c69a746ae5c1c0d847cb5af Mon Sep 17 00:00:00 2001 From: Rob Edwards Date: Thu, 11 Nov 2021 16:50:12 +0000 Subject: [PATCH 2/2] Removed --pdb related code as this option has been added to Django as of version 3.0 https://docs.djangoproject.com/en/3.0/releases/3.0/#tests --- test_extras/management/commands/test.py | 18 +----------------- tox.ini | 12 +++++++++++- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/test_extras/management/commands/test.py b/test_extras/management/commands/test.py index a82b337..d8a250f 100644 --- a/test_extras/management/commands/test.py +++ b/test_extras/management/commands/test.py @@ -3,7 +3,7 @@ # http://www.bright-interactive.com | info@bright-interactive.com from django.conf import settings -from test_extras.testrunners import result_hook_wrap, CoverageTestSuiteWrapper, PdbTestSuiteMixin, XmlTestSuiteMixin, ProfileTestSuiteWrapper, TagTestSuiteMixin +from test_extras.testrunners import result_hook_wrap, CoverageTestSuiteWrapper, XmlTestSuiteMixin, ProfileTestSuiteWrapper, TagTestSuiteMixin from django.core.management.commands.test import Command as CoreCommand import argparse @@ -17,7 +17,6 @@ class Command(CoreCommand): except that it also adds support for: --coverage - --pdb --xmlreports --profile --tags @@ -32,10 +31,6 @@ def add_arguments(self, parser): dest='coverage', default=None, choices=['text', 'html', 'xml'], help='Coverage report; One of \'text\', \'html\', \'xml\''), - parser.add_argument( - '--pdb', action='store_true', dest='pdb', - default=False, - help='Drop into pdb on test failure.'), parser.add_argument( '-x', '--xmlreports', action='store_true', dest='xmlreports', default=False, @@ -86,12 +81,6 @@ def handle(self, *test_labels, **options): TestRunner = result_hook_wrap(TestRunner) - if options['pdb'] and options['xmlreports']: - from optparse import OptionError - raise OptionError("--pdb, -x", "cannot have pdb and xmlreports specified") - - if options['pdb']: - TestRunner = self.pdb_wrap(TestRunner) if options['xmlreports']: TestRunner = self.xml_wrap(TestRunner) @@ -132,11 +121,6 @@ def __init__(self, *args, **kwargs): super(CoverageTestSuiteRunner, self).__init__(subject, report_type, *args, **kwargs) return CoverageTestSuiteRunner - def pdb_wrap(self, Runner): - class PdbTestSuiteRunner(PdbTestSuiteMixin, Runner): - pass - return PdbTestSuiteRunner - def xml_wrap(self, Runner): class XmlTestSuiteRunner(XmlTestSuiteMixin, Runner): pass diff --git a/tox.ini b/tox.ini index d56615a..0f72322 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist= - py36-django229, + py36-django229,py38-django329 [testenv] commands= @@ -20,3 +20,13 @@ deps= basepython=python3.6 deps= {[django229]deps} + +[django329] +deps= + Django>=3.2.9,<4.0a0dev0 + {[base]deps} + +[testenv:py38-django329] +basepython=python3.8 +deps= + {[django329]deps}