diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-06-09 16:07:19 -0700 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-10 08:46:11 +0200 |
commit | e065b293878b1e3ea56655aa9d33e87576cd77ff (patch) | |
tree | 7d0bfab0a0280f7005ff26f955ad8eab2e6fe275 /tests/humanize_tests | |
parent | dcb8f00d06eec99072b78d54215c9a3dc04acb99 (diff) | |
download | django-e065b293878b1e3ea56655aa9d33e87576cd77ff.tar.gz |
Refs #27804 -- Used subTest() in filesizeformat tests and HumanizeTests.
Diffstat (limited to 'tests/humanize_tests')
-rw-r--r-- | tests/humanize_tests/tests.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/humanize_tests/tests.py b/tests/humanize_tests/tests.py index 16e8fa6bfd..7396c417ab 100644 --- a/tests/humanize_tests/tests.py +++ b/tests/humanize_tests/tests.py @@ -31,10 +31,14 @@ class HumanizeTests(SimpleTestCase): def humanize_tester(self, test_list, result_list, method, normalize_result_func=escape): for test_content, result in zip(test_list, result_list): - t = Template('{%% load humanize %%}{{ test_content|%s }}' % method) - rendered = t.render(Context(locals())).strip() - self.assertEqual(rendered, normalize_result_func(result), - msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result)) + with self.subTest(test_content): + t = Template('{%% load humanize %%}{{ test_content|%s }}' % method) + rendered = t.render(Context(locals())).strip() + self.assertEqual( + rendered, + normalize_result_func(result), + msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result) + ) def test_ordinal(self): test_list = ('1', '2', '3', '4', '11', '12', @@ -289,9 +293,10 @@ class HumanizeTests(SimpleTestCase): humanize.datetime = DocumentedMockDateTime try: for test_time_string, expected_natural_time in test_data: - test_time = datetime.datetime.strptime(test_time_string, time_format) - natural_time = humanize.naturaltime(test_time).replace('\xa0', ' ') - self.assertEqual(expected_natural_time, natural_time) + with self.subTest(test_time_string): + test_time = datetime.datetime.strptime(test_time_string, time_format) + natural_time = humanize.naturaltime(test_time).replace('\xa0', ' ') + self.assertEqual(expected_natural_time, natural_time) finally: humanize.datetime = orig_humanize_datetime |