From feb1a0a6922885eb0967428adf39fea9e4170ff8 Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Mon, 4 Sep 2017 02:40:50 +0200 Subject: [PATCH] Refs #27804 -- Used subTest() in a syndication test. --- tests/syndication_tests/tests.py | 33 ++++++++++---------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index e98ac354b0..043533d943 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -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])