From 57b960445113961618b1ecd3561941c9af23b9d4 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 29 Aug 2019 10:58:24 +0200 Subject: [PATCH] Converted auth test to use subTest(). --- tests/auth_tests/test_basic.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py index 886ad360e3..c1b7e60455 100644 --- a/tests/auth_tests/test_basic.py +++ b/tests/auth_tests/test_basic.py @@ -53,14 +53,18 @@ class BasicTestCase(TestCase): def test_user_no_email(self): "Users can be created without an email" - u = User.objects.create_user('testuser1') - self.assertEqual(u.email, '') - - u2 = User.objects.create_user('testuser2', email='') - self.assertEqual(u2.email, '') - - u3 = User.objects.create_user('testuser3', email=None) - self.assertEqual(u3.email, '') + cases = [ + {}, + {'email': ''}, + {'email': None}, + ] + for i, kwargs in enumerate(cases): + with self.subTest(**kwargs): + u = User.objects.create_user( + 'testuser{}'.format(i), + **kwargs + ) + self.assertEqual(u.email, '') def test_superuser(self): "Check the creation and properties of a superuser"