diff options
| author | Bruno Alla <bruno.alla@founders4schools.org.uk> | 2017-03-07 21:00:43 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-05-24 08:36:34 -0400 |
| commit | 6092ea8fa62191bf9ed8ebaae3125dcde9c4bbec (patch) | |
| tree | 4da8346887b1c33e3b0a993eaf780687cdb239b0 /tests/forms_tests/field_tests/test_filepathfield.py | |
| parent | 91b2bc3e70be2632baad86488fb03cf02848b5b6 (diff) | |
Refs #27804 -- Used subTest() in several tests.
Diffstat (limited to 'tests/forms_tests/field_tests/test_filepathfield.py')
| -rw-r--r-- | tests/forms_tests/field_tests/test_filepathfield.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/forms_tests/field_tests/test_filepathfield.py b/tests/forms_tests/field_tests/test_filepathfield.py index cbdf97b4c2..56bf0e9fda 100644 --- a/tests/forms_tests/field_tests/test_filepathfield.py +++ b/tests/forms_tests/field_tests/test_filepathfield.py @@ -38,8 +38,9 @@ class FilePathFieldTest(SimpleTestCase): ('/django/forms/widgets.py', 'widgets.py') ] for exp, got in zip(expected, fix_os_paths(f.choices)): - self.assertEqual(exp[1], got[1]) - self.assertTrue(got[0].endswith(exp[0])) + with self.subTest(expected=exp): + self.assertEqual(exp[1], got[1]) + self.assertTrue(got[0].endswith(exp[0])) msg = "'Select a valid choice. fields.py is not one of the available choices.'" with self.assertRaisesMessage(ValidationError, msg): f.clean('fields.py') @@ -61,8 +62,9 @@ class FilePathFieldTest(SimpleTestCase): ('/django/forms/widgets.py', 'widgets.py') ] for exp, got in zip(expected, fix_os_paths(f.choices)): - self.assertEqual(exp[1], got[1]) - self.assertTrue(got[0].endswith(exp[0])) + with self.subTest(expected=exp): + self.assertEqual(exp[1], got[1]) + self.assertTrue(got[0].endswith(exp[0])) def test_filepathfield_4(self): path = os.path.dirname(os.path.abspath(forms.__file__)) + '/' @@ -80,8 +82,9 @@ class FilePathFieldTest(SimpleTestCase): ('/django/forms/widgets.py', 'widgets.py') ] for exp, got in zip(expected, fix_os_paths(f.choices)): - self.assertEqual(exp[1], got[1]) - self.assertTrue(got[0].endswith(exp[0])) + with self.subTest(expected=exp): + self.assertEqual(exp[1], got[1]) + self.assertTrue(got[0].endswith(exp[0])) def test_filepathfield_folders(self): path = os.path.abspath(os.path.join(__file__, '..', '..')) + '/tests/filepath_test_files/' @@ -93,8 +96,9 @@ class FilePathFieldTest(SimpleTestCase): actual = fix_os_paths(f.choices) self.assertEqual(len(expected), len(actual)) for exp, got in zip(expected, actual): - self.assertEqual(exp[1], got[1]) - self.assertTrue(got[0].endswith(exp[0])) + with self.subTest(expected=exp): + self.assertEqual(exp[1], got[1]) + self.assertTrue(got[0].endswith(exp[0])) f = FilePathField(path=path, allow_folders=True, allow_files=True) f.choices.sort() @@ -110,5 +114,6 @@ class FilePathFieldTest(SimpleTestCase): actual = fix_os_paths(f.choices) self.assertEqual(len(expected), len(actual)) for exp, got in zip(expected, actual): - self.assertEqual(exp[1], got[1]) - self.assertTrue(got[0].endswith(exp[0])) + with self.subTest(expected=exp): + self.assertEqual(exp[1], got[1]) + self.assertTrue(got[0].endswith(exp[0])) |
