diff options
author | za <za@python.or.id> | 2016-10-27 14:53:39 +0700 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-11-10 21:30:21 -0500 |
commit | 321e94fa41b121f65c02119c02098df327bbd569 (patch) | |
tree | ce5476c191d589aca4b124f841dfbccac8dd299f /tests/messages_tests | |
parent | 4bb70cbcc60794f515c9bfefeca87b8272d33c0c (diff) | |
download | django-321e94fa41b121f65c02119c02098df327bbd569.tar.gz |
Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.
Diffstat (limited to 'tests/messages_tests')
-rw-r--r-- | tests/messages_tests/base.py | 14 | ||||
-rw-r--r-- | tests/messages_tests/test_cookie.py | 17 | ||||
-rw-r--r-- | tests/messages_tests/test_fallback.py | 30 | ||||
-rw-r--r-- | tests/messages_tests/test_session.py | 7 |
4 files changed, 27 insertions, 41 deletions
diff --git a/tests/messages_tests/base.py b/tests/messages_tests/base.py index 7b6cd43a1d..d578476f44 100644 --- a/tests/messages_tests/base.py +++ b/tests/messages_tests/base.py @@ -197,8 +197,7 @@ class BaseTests(object): @override_settings(MESSAGE_LEVEL=constants.DEBUG) def test_multiple_posts(self): """ - Tests that messages persist properly when multiple POSTs are made - before a GET. + Messages persist properly when multiple POSTs are made before a GET. """ data = { 'messages': ['Test message %d' % x for x in range(5)], @@ -229,8 +228,8 @@ class BaseTests(object): ) def test_middleware_disabled(self): """ - Tests that, when the middleware is disabled, an exception is raised - when one attempts to store a message. + When the middleware is disabled, an exception is raised when one + attempts to store a message. """ data = { 'messages': ['Test message %d' % x for x in range(5)], @@ -254,8 +253,8 @@ class BaseTests(object): ) def test_middleware_disabled_fail_silently(self): """ - Tests that, when the middleware is disabled, an exception is not - raised if 'fail_silently' = True + When the middleware is disabled, an exception is not raised + if 'fail_silently' = True """ data = { 'messages': ['Test message %d' % x for x in range(5)], @@ -285,8 +284,7 @@ class BaseTests(object): def test_existing_read(self): """ - Tests that reading the existing storage doesn't cause the data to be - lost. + Reading the existing storage doesn't cause the data to be lost. """ storage = self.get_existing_storage() self.assertFalse(storage.used) diff --git a/tests/messages_tests/test_cookie.py b/tests/messages_tests/test_cookie.py index 421ff5b93a..58c7ecfc6c 100644 --- a/tests/messages_tests/test_cookie.py +++ b/tests/messages_tests/test_cookie.py @@ -54,13 +54,13 @@ class CookieTest(BaseTests, SimpleTestCase): # Set initial data. example_messages = ['test', 'me'] set_cookie_data(storage, example_messages) - # Test that the message actually contains what we expect. + # The message actually contains what we expect. self.assertEqual(list(storage), example_messages) def test_cookie_setings(self): """ - Ensure that CookieStorage honors SESSION_COOKIE_DOMAIN, SESSION_COOKIE_SECURE and SESSION_COOKIE_HTTPONLY - Refs #15618 and #20972. + CookieStorage honors SESSION_COOKIE_DOMAIN, SESSION_COOKIE_SECURE, and + SESSION_COOKIE_HTTPONLY (#15618, #20972). """ # Test before the messages have been consumed storage = self.get_storage() @@ -90,14 +90,13 @@ class CookieTest(BaseTests, SimpleTestCase): # Set initial (invalid) data. example_messages = ['test', 'me'] set_cookie_data(storage, example_messages, invalid=True) - # Test that the message actually contains what we expect. + # The message actually contains what we expect. self.assertEqual(list(storage), []) def test_max_cookie_length(self): """ - Tests that, if the data exceeds what is allowed in a cookie, older - messages are removed before saving (and returned by the ``update`` - method). + If the data exceeds what is allowed in a cookie, older messages are + removed before saving (and returned by the ``update`` method). """ storage = self.get_storage() response = self.get_response() @@ -120,7 +119,7 @@ class CookieTest(BaseTests, SimpleTestCase): def test_json_encoder_decoder(self): """ - Tests that a complex nested data structure containing Message + A complex nested data structure containing Message instances is properly encoded/decoded by the custom JSON encoder/decoder classes. """ @@ -140,7 +139,7 @@ class CookieTest(BaseTests, SimpleTestCase): def test_safedata(self): """ - Tests that a message containing SafeData is keeping its safe status when + A message containing SafeData is keeping its safe status when retrieved from the message storage. """ def encode_decode(data): diff --git a/tests/messages_tests/test_fallback.py b/tests/messages_tests/test_fallback.py index 647941b8b2..dfba0a2dc3 100644 --- a/tests/messages_tests/test_fallback.py +++ b/tests/messages_tests/test_fallback.py @@ -25,8 +25,7 @@ class FallbackTest(BaseTests, SimpleTestCase): return storage.storages[-1] def stored_cookie_messages_count(self, storage, response): - return stored_cookie_messages_count(self.get_cookie_storage(storage), - response) + return stored_cookie_messages_count(self.get_cookie_storage(storage), response) def stored_session_messages_count(self, storage, response): return stored_session_messages_count(self.get_session_storage(storage)) @@ -35,9 +34,10 @@ class FallbackTest(BaseTests, SimpleTestCase): """ Return the storage totals from both cookie and session backends. """ - total = (self.stored_cookie_messages_count(storage, response) + - self.stored_session_messages_count(storage, response)) - return total + return ( + self.stored_cookie_messages_count(storage, response) + + self.stored_session_messages_count(storage, response) + ) def test_get(self): request = self.get_request() @@ -52,7 +52,6 @@ class FallbackTest(BaseTests, SimpleTestCase): # used (it would cause a TypeError: 'NoneType' object is not callable). self.get_session_storage(storage)._get = None - # Test that the message actually contains what we expect. self.assertEqual(list(storage), example_messages) def test_get_empty(self): @@ -63,7 +62,6 @@ class FallbackTest(BaseTests, SimpleTestCase): # used (it would cause a TypeError: 'NoneType' object is not callable). self.get_session_storage(storage)._get = None - # Test that the message actually contains what we expect. self.assertEqual(list(storage), []) def test_get_fallback(self): @@ -74,11 +72,9 @@ class FallbackTest(BaseTests, SimpleTestCase): # Set initial cookie and session data. example_messages = [str(i) for i in range(5)] - set_cookie_data(cookie_storage, example_messages[:4] + - [CookieStorage.not_finished]) + set_cookie_data(cookie_storage, example_messages[:4] + [CookieStorage.not_finished]) set_session_data(session_storage, example_messages[4:]) - # Test that the message actually contains what we expect. self.assertEqual(list(storage), example_messages) def test_get_fallback_only(self): @@ -89,11 +85,9 @@ class FallbackTest(BaseTests, SimpleTestCase): # Set initial cookie and session data. example_messages = [str(i) for i in range(5)] - set_cookie_data(cookie_storage, [CookieStorage.not_finished], - encode_empty=True) + set_cookie_data(cookie_storage, [CookieStorage.not_finished], encode_empty=True) set_session_data(session_storage, example_messages) - # Test that the message actually contains what we expect. self.assertEqual(list(storage), example_messages) def test_flush_used_backends(self): @@ -116,8 +110,6 @@ class FallbackTest(BaseTests, SimpleTestCase): def test_no_fallback(self): """ - Confirms that: - (1) A short number of messages whose data size doesn't exceed what is allowed in a cookie will all be stored in the CookieBackend. @@ -142,8 +134,8 @@ class FallbackTest(BaseTests, SimpleTestCase): def test_session_fallback(self): """ - Confirms that, if the data exceeds what is allowed in a cookie, - messages which did not fit are stored in the SessionBackend. + If the data exceeds what is allowed in a cookie, messages which did + not fit are stored in the SessionBackend. """ storage = self.get_storage() response = self.get_response() @@ -161,8 +153,8 @@ class FallbackTest(BaseTests, SimpleTestCase): def test_session_fallback_only(self): """ - Confirms that large messages, none of which fit in a cookie, are stored - in the SessionBackend (and nothing is stored in the CookieBackend). + Large messages, none of which fit in a cookie, are stored in the + SessionBackend (and nothing is stored in the CookieBackend). """ storage = self.get_storage() response = self.get_response() diff --git a/tests/messages_tests/test_session.py b/tests/messages_tests/test_session.py index 3d211f6f8d..868f0931a9 100644 --- a/tests/messages_tests/test_session.py +++ b/tests/messages_tests/test_session.py @@ -36,19 +36,16 @@ class SessionTest(BaseTests, TestCase): def test_get(self): storage = self.storage_class(self.get_request()) - # Set initial data. example_messages = ['test', 'me'] set_session_data(storage, example_messages) - # Test that the message actually contains what we expect. self.assertEqual(list(storage), example_messages) def test_safedata(self): """ - Tests that a message containing SafeData is keeping its safe status when - retrieved from the message storage. + A message containing SafeData keeps its safe status when retrieved from + the message storage. """ storage = self.get_storage() - message = Message(constants.DEBUG, mark_safe("<b>Hello Django!</b>")) set_session_data(storage, [message]) self.assertIsInstance(list(storage)[0].message, SafeData) |