Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #22237 -- Removed some warnings in the test suite

Thanks Aymeric Augustin for the report.
  • Loading branch information...
commit c564277937a1f0b78b2c2b701e6381319d9685c2 1 parent 0e52b28
@claudep claudep authored
View
10 tests/cache/tests.py
@@ -1237,14 +1237,14 @@ def test_default_expiration_time_for_keys_is_5_minutes(self):
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 @@ def test_caches_set_with_timeout_as_none_has_correct_default_timeout(self):
"""
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 @@ def test_caches_with_unset_timeout_set_expiring_key(self):
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 @@ def text_caches_set_with_timeout_as_none_set_non_expiring_key(self):
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(
View
10 tests/fixtures/tests.py
@@ -337,7 +337,10 @@ def test_loaddata_app_option(self):
"""
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 @@ def test_loading_using(self):
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(), [])
View
3  tests/modeladmin/tests.py
@@ -16,6 +16,7 @@
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 @@ def assertIsInvalidRegexp(self, model_admin, model, msg,
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)
View
9 tests/test_runner/tests.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.