1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Refs #27804 -- Used subTest() in several tests.

This commit is contained in:
Bruno Alla
2017-03-07 21:00:43 +00:00
committed by Tim Graham
parent 91b2bc3e70
commit 6092ea8fa6
19 changed files with 324 additions and 262 deletions

View File

@@ -47,32 +47,35 @@ class MultiDatabaseTests(TestCase):
@mock.patch('django.contrib.admin.options.transaction')
def test_add_view(self, mock):
for db in connections:
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_add'),
{'name': 'Foobar: 5th edition'},
)
mock.atomic.assert_called_with(using=db)
with self.subTest(db=db):
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_add'),
{'name': 'Foobar: 5th edition'},
)
mock.atomic.assert_called_with(using=db)
@mock.patch('django.contrib.admin.options.transaction')
def test_change_view(self, mock):
for db in connections:
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_change', args=[self.test_book_ids[db]]),
{'name': 'Test Book 2: Test more'},
)
mock.atomic.assert_called_with(using=db)
with self.subTest(db=db):
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_change', args=[self.test_book_ids[db]]),
{'name': 'Test Book 2: Test more'},
)
mock.atomic.assert_called_with(using=db)
@mock.patch('django.contrib.admin.options.transaction')
def test_delete_view(self, mock):
for db in connections:
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_delete', args=[self.test_book_ids[db]]),
{'post': 'yes'},
)
mock.atomic.assert_called_with(using=db)
with self.subTest(db=db):
Router.target_db = db
self.client.force_login(self.superusers[db])
self.client.post(
reverse('test_adminsite:admin_views_book_delete', args=[self.test_book_ids[db]]),
{'post': 'yes'},
)
mock.atomic.assert_called_with(using=db)