Use subTest for test_bahn, test_bahnen and test_region.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 23 Jul 2017 19:24:08 +0000 (19:24 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 23 Jul 2017 19:24:08 +0000 (19:24 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrfeed/trunk@2660 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrfeed.py

index 6397208ec4546aac3433652dc90d678d5362280b..873ec436948dfc1ddf7d69241263d2e908299d94 100644 (file)
@@ -69,11 +69,12 @@ class TestDbWrfeed(WrfeedTestBase):
             'birgitzer_alm_(vom_adelshof)': 1,
         }
         for bahn, count in bahn_count.items():
-            result = self.app.get('/berichte/bahn/{}'.format(bahn))
-            self.assertTrue(result.data.startswith(b'<?xml'))
-            root = et.fromstring(result.data)
-            self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
-            self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, '"{}" not found {} times'.format(bahn, count))
+            with self.subTest(bahn=bahn):
+                result = self.app.get('/berichte/bahn/{}'.format(bahn))
+                self.assertTrue(result.data.startswith(b'<?xml'))
+                root = et.fromstring(result.data)
+                self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
+                self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, '"{}" not found {} times'.format(bahn, count))
 
     def test_bahnen(self):
         bahnen_count = {
@@ -87,11 +88,12 @@ class TestDbWrfeed(WrfeedTestBase):
             '761+1417+5+228': 5,
         }
         for bahnen, count in bahnen_count.items():
-            result = self.app.get('/berichte/bahnen/{}'.format(bahnen))
-            self.assertTrue(result.data.startswith(b'<?xml'))
-            root = et.fromstring(result.data)
-            self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
-            self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, 'bahnen "{}" not found {} times'.format(bahnen, count))
+            with self.subTest(bahnen=bahnen):
+                result = self.app.get('/berichte/bahnen/{}'.format(bahnen))
+                self.assertTrue(result.data.startswith(b'<?xml'))
+                root = et.fromstring(result.data)
+                self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
+                self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, 'bahnen "{}" not found {} times'.format(bahnen, count))
 
     def test_region(self):
         region_count = {
@@ -100,8 +102,9 @@ class TestDbWrfeed(WrfeedTestBase):
             'innsbruck': 3,
         }
         for region, count in region_count.items():
-            result = self.app.get('/berichte/region/{}'.format(region))
-            self.assertTrue(result.data.startswith(b'<?xml'))
-            root = et.fromstring(result.data)
-            self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
-            self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, '"{}" not found {} times'.format(region, count))
+            with self.subTest(region=region):
+                result = self.app.get('/berichte/region/{}'.format(region))
+                self.assertTrue(result.data.startswith(b'<?xml'))
+                root = et.fromstring(result.data)
+                self.assertIn('Rodelbahnberichte', root.find('{http://www.w3.org/2005/Atom}title').text)
+                self.assertEqual(len(root.findall('{http://www.w3.org/2005/Atom}entry')), count, '"{}" not found {} times'.format(region, count))