From 7552de7866dcd270a0f353b007b4aceaa7f3ff3e Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Mon, 21 Oct 2019 09:55:05 +0100 Subject: Used more specific unittest assertions in tests. * assertIsNone()/assertIsNotNone() instead of comparing to None. * assertLess() for < comparisons. * assertIs() for 'is' expressions. * assertIsInstance() for isinstance() expressions. * rounding of assertAlmostEqual() for round() expressions. * assertIs(..., True/False) instead of comparing to True/False. * assertIs()/assertIsNot() for ==/!= comparisons. * assertNotEqual() for == comparisons. * assertTrue()/assertFalse() instead of comparing to True/False. --- tests/utils_tests/test_encoding.py | 2 +- tests/utils_tests/test_text.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/utils_tests') diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py index 032124b59a..b878988e11 100644 --- a/tests/utils_tests/test_encoding.py +++ b/tests/utils_tests/test_encoding.py @@ -104,7 +104,7 @@ class TestEncodingUtils(SimpleTestCase): class TestRFC3987IEncodingUtils(unittest.TestCase): def test_filepath_to_uri(self): - self.assertEqual(filepath_to_uri(None), None) + self.assertIsNone(filepath_to_uri(None)) self.assertEqual(filepath_to_uri('upload\\чубака.mp4'), 'upload/%D1%87%D1%83%D0%B1%D0%B0%D0%BA%D0%B0.mp4') def test_iri_to_uri(self): diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py index 77d7e73259..b904c228b9 100644 --- a/tests/utils_tests/test_text.py +++ b/tests/utils_tests/test_text.py @@ -250,7 +250,7 @@ class TestUtilsText(SimpleTestCase): actual_length = len(b''.join(seq)) out = text.compress_sequence(seq) compressed_length = len(b''.join(out)) - self.assertTrue(compressed_length < actual_length) + self.assertLess(compressed_length, actual_length) def test_format_lazy(self): self.assertEqual('django/test', format_lazy('{}/{}', 'django', lazystr('test'))) -- cgit v1.3