Refs #27804 -- Used subTest() in a syndication test.

This commit is contained in:
Mads Jensen 2017-09-04 02:40:50 +02:00 committed by Tim Graham
parent 68f0e8d8b1
commit feb1a0a692
1 changed files with 10 additions and 23 deletions

View File

@ -495,27 +495,14 @@ class SyndicationFeedTest(FeedTestCase):
"""
add_domain() prefixes domains onto the correct URLs.
"""
self.assertEqual(
views.add_domain('example.com', '/foo/?arg=value'),
'http://example.com/foo/?arg=value'
)
self.assertEqual(
views.add_domain('example.com', '/foo/?arg=value', True),
'https://example.com/foo/?arg=value'
)
self.assertEqual(
views.add_domain('example.com', 'http://djangoproject.com/doc/'),
'http://djangoproject.com/doc/'
)
self.assertEqual(
views.add_domain('example.com', 'https://djangoproject.com/doc/'),
'https://djangoproject.com/doc/'
)
self.assertEqual(
views.add_domain('example.com', 'mailto:uhoh@djangoproject.com'),
'mailto:uhoh@djangoproject.com'
)
self.assertEqual(
views.add_domain('example.com', '//example.com/foo/?arg=value'),
'http://example.com/foo/?arg=value'
prefix_domain_mapping = (
(('example.com', '/foo/?arg=value'), 'http://example.com/foo/?arg=value'),
(('example.com', '/foo/?arg=value', True), 'https://example.com/foo/?arg=value'),
(('example.com', 'http://djangoproject.com/doc/'), 'http://djangoproject.com/doc/'),
(('example.com', 'https://djangoproject.com/doc/'), 'https://djangoproject.com/doc/'),
(('example.com', 'mailto:uhoh@djangoproject.com'), 'mailto:uhoh@djangoproject.com'),
(('example.com', '//example.com/foo/?arg=value'), 'http://example.com/foo/?arg=value'),
)
for prefix in prefix_domain_mapping:
with self.subTest(prefix=prefix):
self.assertEqual(views.add_domain(*prefix[0]), prefix[1])