diff options
| author | Hasan <hasan.r67@gmail.com> | 2016-01-17 14:56:39 +0330 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-01-29 12:32:18 -0500 |
| commit | 3d0dcd7f5af378d3ab6adb303b913e6c7b2e0ee5 (patch) | |
| tree | 0d1074cc65a72096e44a4165611fddfc5b7ef7fb /tests/custom_pk | |
| parent | 575706331bec4bf58ce36a9540c4c61fca49025b (diff) | |
Refs #26022 -- Used context manager version of assertRaises in tests.
Diffstat (limited to 'tests/custom_pk')
| -rw-r--r-- | tests/custom_pk/tests.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py index 9ba506d953..fdcbd80e04 100644 --- a/tests/custom_pk/tests.py +++ b/tests/custom_pk/tests.py @@ -131,10 +131,8 @@ class BasicCustomPKTests(TestCase): self.assertEqual(Employee.objects.get(pk=123), self.dan) self.assertEqual(Employee.objects.get(pk=456), self.fran) - self.assertRaises( - Employee.DoesNotExist, - lambda: Employee.objects.get(pk=42) - ) + with self.assertRaises(Employee.DoesNotExist): + Employee.objects.get(pk=42) # Use the name of the primary key, rather than pk. self.assertEqual(Employee.objects.get(employee_code=123), self.dan) @@ -151,7 +149,8 @@ class BasicCustomPKTests(TestCase): # Or we can use the real attribute name for the primary key: self.assertEqual(e.employee_code, 123) - self.assertRaises(AttributeError, lambda: e.id) + with self.assertRaises(AttributeError): + e.id def test_in_bulk(self): """ |
