jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/597226 )
Change subject: [tests] Improve test_sort wikistats_tests ......................................................................
[tests] Improve test_sort wikistats_tests
- use a tuple for test keys and use subTest for the tests - reorder remaining tests
Change-Id: I2bf15ff3664e6a8e2fe73987eaa86a7383e131ee --- M tests/wikistats_tests.py 1 file changed, 11 insertions(+), 8 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py index 241e81d..6755ccc 100644 --- a/tests/wikistats_tests.py +++ b/tests/wikistats_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Test cases for the WikiStats dataset.""" # -# (C) Pywikibot team, 2014-2019 +# (C) Pywikibot team, 2014-2020 # # Distributed under the terms of the MIT license. # @@ -23,23 +23,26 @@
def test_sort(self): """Test sorted results.""" + keys = ('good', 'prefix', 'total') + ws = WikiStats() data = ws.sorted('wikipedia', 'total') top = data[0] bottom = data[-1] - self.assertIn('good', top) - self.assertIn('prefix', top) - self.assertIn('total', top) - self.assertIn('good', bottom) - self.assertIn('prefix', bottom) - self.assertIn('total', bottom) - self.assertIsInstance(top['good'], UnicodeType) + + for key in keys: + with self.subTest(key=key): + self.assertIn(key, top) + self.assertIn(key, bottom) + self.assertTrue(all(isinstance(key, UnicodeType) for key in top.keys() if key is not None)) + self.assertIsInstance(top['good'], UnicodeType) self.assertIsInstance(top['total'], UnicodeType) self.assertIsInstance(bottom['good'], UnicodeType) self.assertIsInstance(bottom['total'], UnicodeType) + self.assertGreater(int(top['total']), int(bottom['good'])) self.assertGreater(int(top['good']), int(bottom['good'])) self.assertGreater(int(top['total']), int(bottom['total']))
pywikibot-commits@lists.wikimedia.org