diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/admin_changelist/tests.py | 4 | ||||
-rw-r--r-- | tests/admin_scripts/tests.py | 3 | ||||
-rw-r--r-- | tests/admin_views/admin.py | 3 | ||||
-rw-r--r-- | tests/auth_tests/test_context_processors.py | 16 | ||||
-rw-r--r-- | tests/cache/tests.py | 9 | ||||
-rw-r--r-- | tests/decorators/tests.py | 4 | ||||
-rw-r--r-- | tests/expressions_case/tests.py | 2 | ||||
-rw-r--r-- | tests/files/tests.py | 3 | ||||
-rw-r--r-- | tests/forms_tests/tests/test_forms.py | 19 | ||||
-rw-r--r-- | tests/i18n/utils.py | 2 | ||||
-rw-r--r-- | tests/queries/test_qs_combinators.py | 1 | ||||
-rw-r--r-- | tests/settings_tests/tests.py | 3 | ||||
-rw-r--r-- | tests/template_tests/utils.py | 2 | ||||
-rw-r--r-- | tests/utils_tests/test_simplelazyobject.py | 7 |
14 files changed, 9 insertions, 69 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 33bf85a9ff..b6060ff9a3 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -568,10 +568,6 @@ class ChangeListTests(TestCase): self.assertNotContains(response, '<a href="%s">' % link) def test_tuple_list_display(self): - """ - Regression test for #17128 - (ChangeList failing under Python 2.5 after r16319) - """ swallow = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2') swallow2 = Swallow.objects.create(origin='Africa', load='12.34', speed='22.2') swallow_o2o = SwallowOneToOne.objects.create(swallow=swallow2) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 8494d76f4c..c8f5d2a20d 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -101,9 +101,6 @@ class AdminScriptTestCase(unittest.TestCase): if sys.platform.startswith('java'): # Jython produces module$py.class files os.remove(re.sub(r'\.py$', '$py.class', full_name)) - else: - # CPython produces module.pyc files - os.remove(full_name + 'c') except OSError: pass # Also remove a __pycache__ directory, if it exists diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py index ffce2c0f34..3a5f750309 100644 --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -971,8 +971,7 @@ site.register(RelatedWithUUIDPKModel) # related ForeignKey object not registered in admin # related OneToOne object registered in admin # related OneToOne object not registered in admin -# when deleting Book so as exercise all four troublesome (w.r.t escaping -# and calling force_text to avoid problems on Python 2.3) paths through +# when deleting Book so as exercise all four paths through # contrib.admin.utils's get_deleted_objects function. site.register(Book, inlines=[ChapterInline]) site.register(Promo) diff --git a/tests/auth_tests/test_context_processors.py b/tests/auth_tests/test_context_processors.py index d66b28cb9c..5b93800386 100644 --- a/tests/auth_tests/test_context_processors.py +++ b/tests/auth_tests/test_context_processors.py @@ -130,21 +130,7 @@ class AuthContextProcessorTests(TestCase): # bug #12037 is tested by the {% url %} in the template: self.assertContains(response, "url: /userpage/super/") - # See if this object can be used for queries where a Q() comparing - # a user can be used with another Q() (in an AND or OR fashion). - # This simulates what a template tag might do with the user from the - # context. Note that we don't need to execute a query, just build it. - # - # The failure case (bug #12049) on Python 2.4 with a LazyObject-wrapped - # User is a fatal TypeError: "function() takes at least 2 arguments - # (0 given)" deep inside deepcopy(). - # - # Python 2.5 and 2.6 succeeded, but logged internally caught exception - # spew: - # - # Exception RuntimeError: 'maximum recursion depth exceeded while - # calling a Python object' in <type 'exceptions.AttributeError'> - # ignored" + # A Q() comparing a user and with another Q() (in an AND or OR fashion). Q(user=response.context['user']) & Q(someflag=True) # Tests for user equality. This is hard because User defines diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 5c3ec0fe04..ef77b28458 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -62,11 +62,6 @@ class Unpicklable: raise pickle.PickleError() -class UnpicklableType: - # Unpicklable using the default pickling protocol on Python 2. - __slots__ = 'a', - - @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', @@ -1360,10 +1355,6 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): cache.set('foo', 'bar') os.path.exists(self.dirname) - def test_cache_write_unpicklable_type(self): - # This fails if not using the highest pickling protocol on Python 2. - cache.set('unpicklable', UnpicklableType()) - def test_get_ignores_enoent(self): cache.set('foo', 'bar') os.unlink(cache._key_to_file('foo')) diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py index c2116a05ce..8fedacec22 100644 --- a/tests/decorators/tests.py +++ b/tests/decorators/tests.py @@ -256,8 +256,8 @@ class MethodDecoratorTests(SimpleTestCase): def test_bad_iterable(self): decorators = {myattr_dec_m, myattr2_dec_m} - # The rest of the exception message differs between Python 2 and 3. - with self.assertRaisesMessage(TypeError, "'set' object"): + msg = "'set' object is not subscriptable" + with self.assertRaisesMessage(TypeError, msg): @method_decorator(decorators, "method") class TestIterable: def method(self): diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index a662ffbc3b..20d1e801ec 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -637,8 +637,6 @@ class CaseExpressionTests(TestCase): def test_update_binary(self): CaseTestModel.objects.update( binary=Case( - # fails on postgresql on Python 2.7 if output_field is not - # set explicitly When(integer=1, then=Value(b'one', output_field=models.BinaryField())), When(integer=2, then=Value(b'two', output_field=models.BinaryField())), default=Value(b'', output_field=models.BinaryField()), diff --git a/tests/files/tests.py b/tests/files/tests.py index f7d05574d2..4036fc5e79 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -139,9 +139,6 @@ class FileTests(unittest.TestCase): test_file.seek(0) wrapper = TextIOWrapper(test_file, 'utf-8', newline='\n') self.assertEqual(wrapper.read(), content) - # The following seek() call is required on Windows Python 2 when - # switching from reading to writing. - wrapper.seek(0, 2) wrapper.write(content) wrapper.seek(0) self.assertEqual(wrapper.read(), content * 2) diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 98c5ee8783..c13fbdf5c8 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -21,8 +21,7 @@ from django.template import Context, Template from django.test import SimpleTestCase from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_text -from django.utils.html import format_html -from django.utils.safestring import SafeData, mark_safe +from django.utils.safestring import mark_safe class Person(Form): @@ -2028,22 +2027,6 @@ Password: <input type="password" name="password" required /></li> form = PersonForm({}) self.assertEqual(form['name'].value(), 'John Doe') - def test_boundfield_rendering(self): - """ - Python 2 issue: Rendering a BoundField with bytestring content - doesn't lose it's safe string status (#22950). - """ - class CustomWidget(TextInput): - def render(self, name, value, attrs=None, choices=None, - renderer=None, extra_context=None): - return format_html(str('<input{} />'), ' id=custom') - - class SampleForm(Form): - name = CharField(widget=CustomWidget) - - f = SampleForm(data={'name': 'bar'}) - self.assertIsInstance(force_text(f['name']), SafeData) - def test_custom_boundfield(self): class CustomField(CharField): def get_bound_field(self, form, name): diff --git a/tests/i18n/utils.py b/tests/i18n/utils.py index 2bf4f3e63e..43cb756564 100644 --- a/tests/i18n/utils.py +++ b/tests/i18n/utils.py @@ -7,7 +7,7 @@ source_code_dir = os.path.dirname(__file__) def copytree(src, dst): - shutil.copytree(src, dst, ignore=shutil.ignore_patterns('*.pyc', '__pycache__')) + shutil.copytree(src, dst, ignore=shutil.ignore_patterns('__pycache__')) class POFileAssertionMixin: diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py index 02a0df216d..0528f1c08d 100644 --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -1,7 +1,6 @@ from django.db.models import F, IntegerField, Value from django.db.utils import DatabaseError from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature -from django.utils.six.moves import range from .models import Number, ReservedName diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py index bf015affc2..fa51c0af20 100644 --- a/tests/settings_tests/tests.py +++ b/tests/settings_tests/tests.py @@ -305,8 +305,7 @@ class TestComplexSettingOverride(SimpleTestCase): self.assertEqual(settings.TEST_WARN, 'override') self.assertEqual(len(w), 1) - # File extension may by .py, .pyc, etc. Compare only basename. - self.assertEqual(os.path.splitext(w[0].filename)[0], os.path.splitext(__file__)[0]) + self.assertEqual(w[0].filename, __file__) self.assertEqual(str(w[0].message), 'Overriding setting TEST_WARN can lead to unexpected behavior.') diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py index e2a9305b5e..3ebacf7bcb 100644 --- a/tests/template_tests/utils.py +++ b/tests/template_tests/utils.py @@ -164,7 +164,7 @@ class SilentAttrClass: class UTF8Class: - "Class whose __str__ returns non-ASCII data on Python 2" + "Class whose __str__ returns non-ASCII data" def __str__(self): return 'ŠĐĆŽćžšđ' diff --git a/tests/utils_tests/test_simplelazyobject.py b/tests/utils_tests/test_simplelazyobject.py index a83c78bf4c..d6386fe79c 100644 --- a/tests/utils_tests/test_simplelazyobject.py +++ b/tests/utils_tests/test_simplelazyobject.py @@ -7,15 +7,10 @@ from django.utils.functional import SimpleLazyObject class TestUtilsSimpleLazyObjectDjangoTestCase(TestCase): - def test_pickle_py2_regression(self): - # See ticket #20212 + def test_pickle(self): user = User.objects.create_user('johndoe', 'john@example.com', 'pass') x = SimpleLazyObject(lambda: user) - - # This would fail with "TypeError: can't pickle instancemethod objects", - # only on Python 2.X. pickle.dumps(x) - # Try the variant protocol levels. pickle.dumps(x, 0) pickle.dumps(x, 1) |