diff options
| author | Martin Thoma <info@martin-thoma.de> | 2020-09-24 18:37:55 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-28 20:20:20 +0100 |
| commit | 302caa40e4caab7d95ef7d0a88a90f935039ab09 (patch) | |
| tree | 5508daa6533f00834203e2d38e1f02919f513636 /tests | |
| parent | 4eb756793b64cf153be4fbe0411da6e3e4f1279d (diff) | |
Made small readability improvements.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/tests.py | 14 | ||||
| -rw-r--r-- | tests/cache/tests.py | 2 | ||||
| -rw-r--r-- | tests/schema/tests.py | 2 | ||||
| -rw-r--r-- | tests/view_tests/tests/test_i18n.py | 2 |
4 files changed, 9 insertions, 11 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py index cf6bdbf25d..ed1847ede5 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -665,10 +665,9 @@ class ThreadTests(TransactionTestCase): # (the connection opened in the main thread will automatically be # closed on teardown). for conn in connections_dict.values(): - if conn is not connection: - if conn.allow_thread_sharing: - conn.close() - conn.dec_thread_sharing() + if conn is not connection and conn.allow_thread_sharing: + conn.close() + conn.dec_thread_sharing() def test_connections_thread_local(self): """ @@ -702,10 +701,9 @@ class ThreadTests(TransactionTestCase): # (the connection opened in the main thread will automatically be # closed on teardown). for conn in connections_dict.values(): - if conn is not connection: - if conn.allow_thread_sharing: - conn.close() - conn.dec_thread_sharing() + if conn is not connection and conn.allow_thread_sharing: + conn.close() + conn.dec_thread_sharing() def test_pass_connection_between_threads(self): """ diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 1ef2cc1bc1..367d2d7119 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1714,7 +1714,7 @@ class CacheUtils(SimpleTestCase): def _get_request_cache(self, method='GET', query_string=None, update_cache=None): request = self._get_request(self.host, self.path, method, query_string=query_string) - request._cache_update_cache = True if not update_cache else update_cache + request._cache_update_cache = update_cache if update_cache else True return request def test_patch_vary_headers(self): diff --git a/tests/schema/tests.py b/tests/schema/tests.py index a7743deba4..b986f27aa1 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -161,7 +161,7 @@ class SchemaTests(TransactionTestCase): schema_editor.add_field(model, field) cursor.execute("SELECT {} FROM {};".format(field_name, model._meta.db_table)) database_default = cursor.fetchall()[0][0] - if cast_function and not type(database_default) == type(expected_default): + if cast_function and type(database_default) != type(expected_default): database_default = cast_function(database_default) self.assertEqual(database_default, expected_default) diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index 0ec2bf877e..84dff20753 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -25,7 +25,7 @@ class SetLanguageTests(TestCase): def _get_inactive_language_code(self): """Return language code for a language which is not activated.""" current_language = get_language() - return [code for code, name in settings.LANGUAGES if not code == current_language][0] + return [code for code, name in settings.LANGUAGES if code != current_language][0] def test_setlang(self): """ |
