jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[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(-)

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']))

To view, visit change 597226. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2bf15ff3664e6a8e2fe73987eaa86a7383e131ee
Gerrit-Change-Number: 597226
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)