diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/admin_scripts/tests.py | 3 | ||||
-rw-r--r-- | tests/mail/tests.py | 5 | ||||
-rw-r--r-- | tests/migrations/test_writer.py | 6 | ||||
-rw-r--r-- | tests/model_inheritance/tests.py | 4 | ||||
-rwxr-xr-x | tests/runtests.py | 2 | ||||
-rw-r--r-- | tests/transactions/tests.py | 2 | ||||
-rw-r--r-- | tests/utils_tests/test_functional.py | 30 | ||||
-rw-r--r-- | tests/view_tests/tests/test_debug.py | 3 |
8 files changed, 5 insertions, 50 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index aeec3724b6..8e00a86071 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -32,7 +32,6 @@ from django.db.migrations.recorder import MigrationRecorder from django.test import ( LiveServerTestCase, SimpleTestCase, TestCase, override_settings, ) -from django.utils.version import PY36 custom_templates_dir = os.path.join(os.path.dirname(__file__), 'custom_templates') @@ -1145,7 +1144,7 @@ class ManageCheck(AdminScriptTestCase): args = ['check'] out, err = self.run_manage(args) self.assertNoOutput(out) - self.assertOutput(err, 'ModuleNotFoundError' if PY36 else 'ImportError') + self.assertOutput(err, 'ModuleNotFoundError') self.assertOutput(err, 'No module named') self.assertOutput(err, 'admin_scriptz') diff --git a/tests/mail/tests.py b/tests/mail/tests.py index e283101b79..029d332c42 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -1211,10 +1211,7 @@ class FakeSMTPServer(smtpd.SMTPServer, threading.Thread): def __init__(self, *args, **kwargs): threading.Thread.__init__(self) - # New kwarg added in Python 3.5; default switching to False in 3.6. - # Setting a value only silences a deprecation warning in Python 3.5. - kwargs['decode_data'] = True - smtpd.SMTPServer.__init__(self, *args, **kwargs) + smtpd.SMTPServer.__init__(self, *args, decode_data=True, **kwargs) self._sink = [] self.active = False self.active_lock = threading.Lock() diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index abeeaf5182..dd7cff2abb 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -22,7 +22,6 @@ from django.utils.deconstruct import deconstructible from django.utils.functional import SimpleLazyObject from django.utils.timezone import get_default_timezone, get_fixed_timezone, utc from django.utils.translation import gettext_lazy as _ -from django.utils.version import PY36 from .models import FoodManager, FoodQuerySet @@ -413,10 +412,7 @@ class WriterTests(SimpleTestCase): # Test a string regex with flag validator = RegexValidator(r'^[0-9]+$', flags=re.S) string = MigrationWriter.serialize(validator)[0] - if PY36: - self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=re.RegexFlag(16))") - else: - self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=16)") + self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=re.RegexFlag(16))") self.serialize_round_trip(validator) # Test message and code diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py index 5f89b4aa83..5eef0f5bfa 100644 --- a/tests/model_inheritance/tests.py +++ b/tests/model_inheritance/tests.py @@ -1,11 +1,9 @@ -import unittest from operator import attrgetter from django.core.exceptions import FieldError, ValidationError from django.db import connection, models from django.test import SimpleTestCase, TestCase from django.test.utils import CaptureQueriesContext, isolate_apps -from django.utils.version import PY36 from .models import ( Base, Chef, CommonInfo, GrandChild, GrandParent, ItalianRestaurant, @@ -176,7 +174,6 @@ class ModelInheritanceTests(TestCase): self.assertIs(C._meta.parents[A], C._meta.get_field('a')) - @unittest.skipUnless(PY36, 'init_subclass is new in Python 3.6') @isolate_apps('model_inheritance') def test_init_subclass(self): saved_kwargs = {} @@ -193,7 +190,6 @@ class ModelInheritanceTests(TestCase): self.assertEqual(saved_kwargs, kwargs) - @unittest.skipUnless(PY36, '__set_name__ is new in Python 3.6') @isolate_apps('model_inheritance') def test_set_name(self): class ClassAttr: diff --git a/tests/runtests.py b/tests/runtests.py index 871b6c202d..0861ec8798 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -234,7 +234,7 @@ def teardown(state): # Discard the multiprocessing.util finalizer that tries to remove a # temporary directory that's already removed by this script's # atexit.register(shutil.rmtree, TMPDIR) handler. Prevents - # FileNotFoundError at the end of a test run on Python 3.6+ (#27890). + # FileNotFoundError at the end of a test run (#27890). from multiprocessing.util import _finalizer_registry _finalizer_registry.pop((-100, 0), None) diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py index af3416aeaa..2ac2f8cc84 100644 --- a/tests/transactions/tests.py +++ b/tests/transactions/tests.py @@ -228,7 +228,6 @@ class AtomicInsideTransactionTests(AtomicTests): self.atomic.__exit__(*sys.exc_info()) -@skipIfDBFeature('autocommits_when_autocommit_is_off') class AtomicWithoutAutocommitTests(AtomicTests): """All basic tests for atomic should also pass when autocommit is turned off.""" @@ -480,7 +479,6 @@ class AtomicMiscTests(TransactionTestCase): Reporter.objects.create() -@skipIfDBFeature('autocommits_when_autocommit_is_off') class NonAutocommitTests(TransactionTestCase): available_apps = [] diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py index 8d26a906b9..ab649b7983 100644 --- a/tests/utils_tests/test_functional.py +++ b/tests/utils_tests/test_functional.py @@ -1,8 +1,5 @@ -import unittest - from django.test import SimpleTestCase from django.utils.functional import cached_property, lazy -from django.utils.version import PY36 class FunctionalTests(SimpleTestCase): @@ -104,7 +101,6 @@ class FunctionalTests(SimpleTestCase): for attr in attrs: self.assertCachedPropertyWorks(attr, Class) - @unittest.skipUnless(PY36, '__set_name__ is new in Python 3.6') def test_cached_property_auto_name(self): """ cached_property caches its value and behaves like a property @@ -132,7 +128,6 @@ class FunctionalTests(SimpleTestCase): obj.other2 self.assertFalse(hasattr(obj, 'different_name')) - @unittest.skipUnless(PY36, '__set_name__ is new in Python 3.6') def test_cached_property_reuse_different_names(self): """Disallow this case because the decorated function wouldn't be cached.""" with self.assertRaises(RuntimeError) as ctx: @@ -151,7 +146,6 @@ class FunctionalTests(SimpleTestCase): )) ) - @unittest.skipUnless(PY36, '__set_name__ is new in Python 3.6') def test_cached_property_reuse_same_name(self): """ Reusing a cached_property on different classes under the same name is @@ -177,7 +171,6 @@ class FunctionalTests(SimpleTestCase): self.assertEqual(b.cp, 2) self.assertEqual(a.cp, 1) - @unittest.skipUnless(PY36, '__set_name__ is new in Python 3.6') def test_cached_property_set_name_not_called(self): cp = cached_property(lambda s: None) @@ -189,29 +182,6 @@ class FunctionalTests(SimpleTestCase): with self.assertRaisesMessage(TypeError, msg): Foo().cp - @unittest.skipIf(PY36, '__set_name__ is new in Python 3.6') - def test_cached_property_mangled_error(self): - msg = ( - 'cached_property does not work with mangled methods on ' - 'Python < 3.6 without the appropriate `name` argument.' - ) - with self.assertRaisesMessage(ValueError, msg): - @cached_property - def __value(self): - pass - with self.assertRaisesMessage(ValueError, msg): - def func(self): - pass - cached_property(func, name='__value') - - @unittest.skipIf(PY36, '__set_name__ is new in Python 3.6') - def test_cached_property_name_validation(self): - msg = "%s can't be used as the name of a cached_property." - with self.assertRaisesMessage(ValueError, msg % "'<lambda>'"): - cached_property(lambda x: None) - with self.assertRaisesMessage(ValueError, msg % 42): - cached_property(str, name=42) - def test_lazy_equality(self): """ == and != work correctly for Promises. diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index db23d10d32..1ff1220803 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -17,7 +17,6 @@ from django.test.utils import LoggingCaptureMixin from django.urls import path, reverse from django.utils.functional import SimpleLazyObject from django.utils.safestring import mark_safe -from django.utils.version import PY36 from django.views.debug import ( CLEANSED_SUBSTITUTE, CallableSettingWrapper, ExceptionReporter, cleanse_setting, technical_500_response, @@ -515,7 +514,7 @@ class ExceptionReporterTests(SimpleTestCase): exc_type, exc_value, tb = sys.exc_info() reporter = ExceptionReporter(request, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertInHTML('<h1>%sError at /test_view/</h1>' % ('ModuleNotFound' if PY36 else 'Import'), html) + self.assertInHTML('<h1>ModuleNotFoundError at /test_view/</h1>', html) def test_ignore_traceback_evaluation_exceptions(self): """ |