mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #22237 -- Removed some warnings in the test suite
Thanks Aymeric Augustin for the report.
This commit is contained in:
parent
0e52b2863b
commit
c564277937
10
tests/cache/tests.py
vendored
10
tests/cache/tests.py
vendored
@ -1237,14 +1237,14 @@ class DefaultNonExpiringCacheKeyTests(TestCase):
|
||||
This value is defined inside the __init__() method of the
|
||||
:class:`django.core.cache.backends.base.BaseCache` type.
|
||||
"""
|
||||
self.assertEquals(300, self.DEFAULT_TIMEOUT)
|
||||
self.assertEqual(300, self.DEFAULT_TIMEOUT)
|
||||
|
||||
def test_caches_with_unset_timeout_has_correct_default_timeout(self):
|
||||
"""Caches that have the TIMEOUT parameter undefined in the default
|
||||
settings will use the default 5 minute timeout.
|
||||
"""
|
||||
cache = caches[DEFAULT_CACHE_ALIAS]
|
||||
self.assertEquals(self.DEFAULT_TIMEOUT, cache.default_timeout)
|
||||
self.assertEqual(self.DEFAULT_TIMEOUT, cache.default_timeout)
|
||||
|
||||
@override_settings(CACHES=NEVER_EXPIRING_CACHES_SETTINGS)
|
||||
def test_caches_set_with_timeout_as_none_has_correct_default_timeout(self):
|
||||
@ -1255,7 +1255,7 @@ class DefaultNonExpiringCacheKeyTests(TestCase):
|
||||
"""
|
||||
cache = caches[DEFAULT_CACHE_ALIAS]
|
||||
self.assertIs(None, cache.default_timeout)
|
||||
self.assertEquals(None, cache.get_backend_timeout())
|
||||
self.assertEqual(None, cache.get_backend_timeout())
|
||||
|
||||
@override_settings(CACHES=DEFAULT_MEMORY_CACHES_SETTINGS)
|
||||
def test_caches_with_unset_timeout_set_expiring_key(self):
|
||||
@ -1267,7 +1267,7 @@ class DefaultNonExpiringCacheKeyTests(TestCase):
|
||||
cache = caches[DEFAULT_CACHE_ALIAS]
|
||||
cache.set(key, value)
|
||||
cache_key = cache.make_key(key)
|
||||
self.assertNotEquals(None, cache._expire_info[cache_key])
|
||||
self.assertNotEqual(None, cache._expire_info[cache_key])
|
||||
|
||||
@override_settings(CACHES=NEVER_EXPIRING_CACHES_SETTINGS)
|
||||
def text_caches_set_with_timeout_as_none_set_non_expiring_key(self):
|
||||
@ -1279,7 +1279,7 @@ class DefaultNonExpiringCacheKeyTests(TestCase):
|
||||
cache = caches[DEFAULT_CACHE_ALIAS]
|
||||
cache.set(key, value)
|
||||
cache_key = cache.make_key(key)
|
||||
self.assertEquals(None, cache._expire_info[cache_key])
|
||||
self.assertEqual(None, cache._expire_info[cache_key])
|
||||
|
||||
|
||||
@override_settings(
|
||||
|
10
tests/fixtures/tests.py
vendored
10
tests/fixtures/tests.py
vendored
@ -337,7 +337,10 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
|
||||
"""
|
||||
Verifies that the --app option works.
|
||||
"""
|
||||
management.call_command('loaddata', 'db_fixture_1', verbosity=0, app_label="someotherapp")
|
||||
with warnings.catch_warnings():
|
||||
# Ignore: No fixture named ...
|
||||
warnings.filterwarnings("ignore", category=UserWarning)
|
||||
management.call_command('loaddata', 'db_fixture_1', verbosity=0, app_label="someotherapp")
|
||||
self.assertQuerysetEqual(Article.objects.all(), [])
|
||||
management.call_command('loaddata', 'db_fixture_1', verbosity=0, app_label="fixtures")
|
||||
self.assertQuerysetEqual(Article.objects.all(), [
|
||||
@ -355,10 +358,9 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
|
||||
|
||||
def test_unmatched_identifier_loading(self):
|
||||
# Try to load db fixture 3. This won't load because the database identifier doesn't match
|
||||
with warnings.catch_warnings(record=True):
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("ignore", category=UserWarning)
|
||||
management.call_command('loaddata', 'db_fixture_3', verbosity=0)
|
||||
|
||||
with warnings.catch_warnings(record=True):
|
||||
management.call_command('loaddata', 'db_fixture_3', verbosity=0, using='default')
|
||||
self.assertQuerysetEqual(Article.objects.all(), [])
|
||||
|
||||
|
@ -16,6 +16,7 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
from django.forms.models import BaseModelFormSet
|
||||
from django.forms.widgets import Select
|
||||
from django.test import TestCase
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango19Warning
|
||||
|
||||
from .models import Band, Concert, ValidationTestModel, ValidationTestInlineModel
|
||||
@ -565,7 +566,7 @@ class CheckTestCase(TestCase):
|
||||
self.assertEqual(error.hint, hint)
|
||||
self.assertEqual(error.obj, invalid_obj)
|
||||
self.assertEqual(error.id, id)
|
||||
self.assertRegexpMatches(error.msg, msg)
|
||||
six.assertRegex(self, error.msg, msg)
|
||||
|
||||
def assertIsValid(self, model_admin, model):
|
||||
errors = model_admin.check(model=model)
|
||||
|
@ -254,21 +254,22 @@ class Sqlite3InMemoryTestDbs(TestCase):
|
||||
def test_transaction_support(self):
|
||||
"""Ticket #16329: sqlite3 in-memory test databases"""
|
||||
old_db_connections = db.connections
|
||||
for option in ('NAME', 'TEST_NAME'):
|
||||
for option_key, option_value in (
|
||||
('NAME', ':memory:'), ('TEST', {'NAME': ':memory:'})):
|
||||
try:
|
||||
db.connections = db.ConnectionHandler({
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
option: ':memory:',
|
||||
option_key: option_value,
|
||||
},
|
||||
'other': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
option: ':memory:',
|
||||
option_key: option_value,
|
||||
},
|
||||
})
|
||||
other = db.connections['other']
|
||||
runner.DiscoverRunner(verbosity=0).setup_databases()
|
||||
msg = "DATABASES setting '%s' option set to sqlite3's ':memory:' value shouldn't interfere with transaction support detection." % option
|
||||
msg = "DATABASES setting '%s' option set to sqlite3's ':memory:' value shouldn't interfere with transaction support detection." % option_key
|
||||
# Transaction support should be properly initialized for the 'other' DB
|
||||
self.assertTrue(other.features.supports_transactions, msg)
|
||||
# And all the DBs should report that they support transactions
|
||||
|
Loading…
Reference in New Issue
Block a user