XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231968

Change subject: [IMPROV] Add docstrings to various test modules
......................................................................

[IMPROV] Add docstrings to various test modules

Change-Id: I4bfa6f9c63b08279477d8b4af77d1b99806a6ef9
---
M tests/api_tests.py
M tests/dry_api_tests.py
M tests/dry_site_tests.py
M tests/i18n_tests.py
M tests/isbn_tests.py
M tests/textlib_tests.py
M tox.ini
7 files changed, 107 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/68/231968/1

diff --git a/tests/api_tests.py b/tests/api_tests.py
index 822f70a..0e221e4 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -153,6 +153,7 @@
     """Test ParamInfo."""
 
     def test_init(self):
+        """Test common initialization."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertEqual(len(pi), 0)
@@ -188,6 +189,7 @@
         self.assertIn('query', pi._paraminfo)
 
     def test_init_pageset(self):
+        """Test initializing with only the pageset."""
         site = self.get_site()
         self.assertNotIn('query', api.ParamInfo.init_modules)
         pi = api.ParamInfo(site, set(['pageset']))
@@ -218,6 +220,7 @@
             self.assertGreater(len(generators_param['type']), 1)
 
     def test_generators(self):
+        """Test requesting the generator parameter."""
         site = self.get_site()
         pi = api.ParamInfo(site, set(['pageset', 'query']))
         self.assertEqual(len(pi), 0)
@@ -236,6 +239,7 @@
             self.assertEqual(pageset_generators_param, query_generators_param)
 
     def test_with_module_info(self):
+        """Test requesting the module info."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertEqual(len(pi), 0)
@@ -264,6 +268,7 @@
         self.assertIn('protection', param['type'])
 
     def test_with_module_revisions(self):
+        """Test requesting the module revisions."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertEqual(len(pi), 0)
@@ -292,6 +297,7 @@
         self.assertIn('user', param['type'])
 
     def test_multiple_modules(self):
+        """Test requesting multiple modules in one fetch."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertEqual(len(pi), 0)
@@ -309,6 +315,7 @@
                          2 + len(pi.preloaded_modules))
 
     def test_with_invalid_module(self):
+        """Test requesting different kind of invalid modules."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertEqual(len(pi), 0)
@@ -345,6 +352,7 @@
         self.assertRaises(KeyError, pi.submodules, 'edit')
 
     def test_query_modules_with_limits(self):
+        """Test query_modules_with_limits property."""
         site = self.get_site()
         pi = api.ParamInfo(site)
         self.assertIn('revisions', pi.query_modules_with_limits)
@@ -396,6 +404,7 @@
             self.assertEqual(value, '')
 
     def test_old_mode(self):
+        """Test the old mode explicitly."""
         site = self.get_site()
         pi = api.ParamInfo(site, modules_only_mode=False)
         pi.fetch(['info'])
@@ -411,6 +420,7 @@
         self.assertIn('revisions', pi.prefixes)
 
     def test_new_mode(self):
+        """Test the new modules-only mode explicitly."""
         site = self.get_site()
         if MediaWikiVersion(site.version()) < MediaWikiVersion('1.25wmf4'):
             raise unittest.SkipTest(
@@ -574,19 +584,23 @@
         self.assertPagelistTitles(self.gen, self.titles)
 
     def test_initial_limit(self):
+        """Test the default limit."""
         self.assertEqual(self.gen.limit, None)  # limit is initally None
 
     def test_set_limit_as_number(self):
+        """Test setting the limit using an int."""
         for i in range(-2, 4):
             self.gen.set_maximum_items(i)
             self.assertEqual(self.gen.limit, i)
 
     def test_set_limit_as_string(self):
+        """Test setting the limit using an int cast into a string."""
         for i in range(-2, 4):
             self.gen.set_maximum_items(str(i))
             self.assertEqual(self.gen.limit, i)
 
     def test_set_limit_not_number(self):
+        """Test setting the limit to not a number."""
         with self.assertRaisesRegex(
                 ValueError,
                 "invalid literal for int\(\) with base 10: 'test'"):
@@ -792,6 +806,7 @@
     cached = False
 
     def test_normal_use(self):
+        """Test the caching of CachedRequest with an ordinary request."""
         mysite = self.get_site()
         mainpage = self.get_mainpage()
         # Run the cached query three times to ensure the
@@ -817,6 +832,7 @@
         self.assertEqual(req2._cachetime, req3._cachetime)
 
     def test_internals(self):
+        """Test the caching of CachedRequest by faking a unique request."""
         mysite = self.get_site()
         # Run tests on a missing page unique to this test run so it can
         # not be cached the first request, but will be cached after.
@@ -879,10 +895,12 @@
     # pywikibot is not connected to a tty. T100964
 
     def setUp(self):
+        """Patch the LoginManager to avoid UI interaction."""
         self.orig_login_manager = pywikibot.data.api.LoginManager
         pywikibot.data.api.LoginManager = FakeLoginManager
 
     def tearDown(self):
+        """Restore the original LoginManager."""
         pywikibot.data.api.LoginManager = self.orig_login_manager
 
     def test_access_denied_notexist_username(self):
@@ -925,6 +943,7 @@
     write = True
 
     def test_bad_token(self):
+        """Test the bad token recovery by corrupting the cache."""
         site = self.get_site()
         site.tokens._tokens.setdefault(site.user(), {})['edit'] = 'INVALID'
         page = pywikibot.Page(site, 'Pywikibot bad token test')
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 5266256..a475100 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -47,6 +47,7 @@
     dry = True
 
     def setUp(self):
+        """Initialize the fake requests."""
         super(DryCachedRequestTests, self).setUp()
         self.parms = {'site': self.basesite,
                       'action': 'query',
@@ -57,23 +58,28 @@
         self.diffsite = CachedRequest(expiry=1, site=self.altsite, 
action='query', meta='userinfo')
 
     def test_expiry_formats(self):
+        """Test using a timedelta as expiry."""
         self.assertEqual(self.req.expiry,
                          CachedRequest(datetime.timedelta(days=1), 
**self.parms).expiry)
 
     def test_expired(self):
+        """Test if the request is expired."""
         self.assertFalse(self.req._expired(datetime.datetime.now()))
         self.assertTrue(self.req._expired(datetime.datetime.now() - 
datetime.timedelta(days=2)))
 
     def test_get_cache_dir(self):
+        """Test that 'apicache' is in the cache dir."""
         retval = self.req._get_cache_dir()
         self.assertIn('apicache', retval)
 
     def test_create_file_name(self):
+        """Test the file names for the cache."""
         self.assertEqual(self.req._create_file_name(), 
self.req._create_file_name())
         self.assertEqual(self.req._create_file_name(), 
self.expreq._create_file_name())
         self.assertNotEqual(self.req._create_file_name(), 
self.diffreq._create_file_name())
 
     def test_cachefile_path(self):
+        """Test the file paths for the cache."""
         self.assertEqual(self.req._cachefile_path(), 
self.req._cachefile_path())
         self.assertEqual(self.req._cachefile_path(), 
self.expreq._cachefile_path())
         self.assertNotEqual(self.req._cachefile_path(), 
self.diffreq._cachefile_path())
@@ -87,6 +93,7 @@
     net = False
 
     def setUp(self):
+        """Create a mock family and site."""
         class MockFamily(Family):
 
             @property
@@ -136,6 +143,7 @@
         super(MockCachedRequestKeyTests, self).setUp()
 
     def test_cachefile_path_different_users(self):
+        """Test and compare the file paths when different usernames are 
used."""
         req = CachedRequest(expiry=1, site=self.mocksite,
                             action='query', meta='siteinfo')
         anonpath = req._cachefile_path()
@@ -158,6 +166,7 @@
         self.assertNotEqual(userpath, sysoppath)
 
     def test_unicode(self):
+        """Test caching with Unicode content."""
         self.mocksite._userinfo = {'name': u'محمد الفلسطيني'}
         self.mocksite._loginstatus = 0
 
@@ -337,6 +346,7 @@
         site._paraminfo._modules = {'query': frozenset(['info'])}
 
     def test_new_format(self):
+        """Test using a dummy formatted in the new modules-only mode."""
         pi = self.get_site()._paraminfo
         # Set it to the new limited set of keys.
         pi.paraminfo_keys = frozenset(['modules'])
@@ -357,6 +367,7 @@
         self.assertIn('info', pi)
 
     def test_old_format(self):
+        """Test using a dummy formatted in the old mode."""
         pi = self.get_site()._paraminfo
         # Reset it to the complete set of possible keys defined in the class
         pi.paraminfo_keys = ParamInfo.paraminfo_keys
@@ -375,6 +386,7 @@
         self.assertIn('info', pi)
 
     def test_attribute(self):
+        """Test using __getitem__."""
         pi = self.get_site()._paraminfo
         # Reset it to the complete set of possible keys defined in the class
         pi.paraminfo_keys = ParamInfo.paraminfo_keys
@@ -391,6 +403,7 @@
         self.assertEqual(pi['info']['prefix'], 'in')
 
     def test_parameter(self):
+        """Test parameter() method."""
         pi = self.get_site()._paraminfo
         # Reset it to the complete set of possible keys defined in the class
         pi.paraminfo_keys = ParamInfo.paraminfo_keys
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index 551881e..e287962 100644
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -31,6 +31,7 @@
     dry = True
 
     def test_logged_in(self):
+        """Test logged_in() method."""
         x = self.get_site()
 
         x._userinfo = {'name': None, 'groups': []}
@@ -49,6 +50,7 @@
         self.assertFalse(x.logged_in(False))
 
     def test_user_agent(self):
+        """Test different variants of user agents."""
         x = self.get_site()
 
         x._userinfo = {'name': 'foo'}
@@ -108,6 +110,7 @@
     # Implemented without setUpClass(cls) and global variables as objects
     # were not completely disposed and recreated but retained 'memory'
     def setUp(self):
+        """Creating fake variables to appear as a site."""
         self.code = 'test'
         self.family = lambda: None
         self.family.name = 'test'
@@ -117,25 +120,30 @@
         self.version = lambda: '1.13'  # pre 1.14
 
     def login(self, sysop):
-        # mock call
+        """Fake the log in and just store who logged in."""
         self._logged_in_as = 'sysop' if sysop else 'user'
 
     def testMockInTest(self):
+        """Test that setUp and login work."""
         self.assertEqual(self._logged_in_as, None)
         self.login(True)
         self.assertEqual(self._logged_in_as, 'sysop')
 
+    # Test that setUp is actually called between each test
     testMockInTestReset = testMockInTest
 
     @must_be('sysop')
     def call_this_sysop_req_function(self, *args, **kwargs):
+        """Require a sysop to function."""
         return args, kwargs
 
     @must_be('user')
     def call_this_user_req_function(self, *args, **kwargs):
+        """Require a user to function."""
         return args, kwargs
 
     def testMustBeSysop(self):
+        """Test a function which requires a sysop."""
         args = (1, 2, 'a', 'b')
         kwargs = {'i': 'j', 'k': 'l'}
         retval = self.call_this_sysop_req_function(*args, **kwargs)
@@ -144,6 +152,7 @@
         self.assertEqual(self._logged_in_as, 'sysop')
 
     def testMustBeUser(self):
+        """Test a function which requires a user."""
         args = (1, 2, 'a', 'b')
         kwargs = {'i': 'j', 'k': 'l'}
         retval = self.call_this_user_req_function(*args, **kwargs)
@@ -152,6 +161,7 @@
         self.assertEqual(self._logged_in_as, 'user')
 
     def testOverrideUserType(self):
+        """Test overriding the required group."""
         args = (1, 2, 'a', 'b')
         kwargs = {'i': 'j', 'k': 'l'}
         retval = self.call_this_user_req_function(*args, as_group='sysop', 
**kwargs)
@@ -160,6 +170,7 @@
         self.assertEqual(self._logged_in_as, 'sysop')
 
     def testObsoleteSite(self):
+        """Test when the site is obsolete and shouldn't be edited."""
         self.obsolete = True
         args = (1, 2, 'a', 'b')
         kwargs = {'i': 'j', 'k': 'l'}
@@ -180,37 +191,45 @@
 
     @need_version("1.14")
     def too_new(self):
+        """Method which is to new."""
         return True
 
     @need_version("1.13")
     def old_enough(self):
+        """Method which is as new as the server."""
         return True
 
     @need_version("1.12")
     def older(self):
+        """Method which is old enough."""
         return True
 
     @need_version("1.14")
     @deprecated
     def deprecated_unavailable_method(self):
+        """Method which is to new and then deprecated."""
         return True
 
     @deprecated
     @need_version("1.14")
     def deprecated_unavailable_method2(self):
+        """Method which is deprecated first and then to new."""
         return True
 
     @need_version("1.12")
     @deprecated
     def deprecated_available_method(self):
+        """Method which is old enough and then deprecated."""
         return True
 
     @deprecated
     @need_version("1.12")
     def deprecated_available_method2(self):
+        """Method which is deprecated first and then old enough."""
         return True
 
     def test_need_version(self):
+        """Test need_version when the version is to new, exact or old 
enough."""
         self.assertRaises(NotImplementedError, self.too_new)
         self.assertTrue(self.old_enough())
         self.assertTrue(self.older())
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index aeb214e..b5a0b86 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -38,6 +38,7 @@
         super(TestTranslate, self).setUp()
 
     def testLocalized(self):
+        """Test fully localized translations."""
         self.assertEqual(i18n.translate('en', self.msg_localized,
                                         fallback=True),
                          u'test-localized EN')
@@ -49,6 +50,7 @@
                          u'test-localized FY')
 
     def testSemiLocalized(self):
+        """Test translate by fallback to an alternative language."""
         self.assertEqual(i18n.translate('en', self.msg_semi_localized,
                                         fallback=True),
                          u'test-semi-localized EN')
@@ -60,6 +62,7 @@
                          u'test-semi-localized NL')
 
     def testNonLocalized(self):
+        """Test translate with missing localisation."""
         self.assertEqual(i18n.translate('en', self.msg_non_localized,
                                         fallback=True),
                          u'test-non-localized EN')
@@ -74,6 +77,7 @@
                          u'test-non-localized EN')
 
     def testNoEnglish(self):
+        """Test translate with missing English text."""
         self.assertEqual(i18n.translate('en', self.msg_no_english,
                                         fallback=True),
                          u'test-no-english JA')
@@ -90,11 +94,13 @@
     """Base class for tests using config.userinterface_lang."""
 
     def setUp(self):
+        """Change the userinterface language to the site's code."""
         super(UserInterfaceLangTestCase, self).setUp()
         self.orig_userinterface_lang = pywikibot.config.userinterface_lang
         pywikibot.config.userinterface_lang = self.get_site().code
 
     def tearDown(self):
+        """Reset the userinterface language."""
         pywikibot.config.userinterface_lang = self.orig_userinterface_lang
         super(UserInterfaceLangTestCase, self).tearDown()
 
@@ -106,11 +112,13 @@
     message_package = None
 
     def setUp(self):
+        """Load the test translations."""
         self.orig_messages_package_name = i18n._messages_package_name
         i18n.set_messages_package(self.message_package)
         super(TWNSetMessagePackageBase, self).setUp()
 
     def tearDown(self):
+        """Load the original translations back."""
         super(TWNSetMessagePackageBase, self).tearDown()
         i18n.set_messages_package(self.orig_messages_package_name)
 
@@ -121,6 +129,7 @@
 
     @classmethod
     def setUpClass(cls):
+        """Verify that the test translations are not empty."""
         if not isinstance(cls.message_package, basestring):
             raise TypeError('%s.message_package must be a package name'
                             % cls.__name__)
@@ -145,6 +154,7 @@
     message_package = 'tests.i18n'
 
     def testLocalized(self):
+        """Test fully localized entry."""
         self.assertEqual(i18n.twtranslate('en', 'test-localized'),
                          u'test-localized EN')
         self.assertEqual(i18n.twtranslate('nl', 'test-localized'),
@@ -153,6 +163,7 @@
                          u'test-localized FY')
 
     def testSemiLocalized(self):
+        """Test translating with fallback to alternative language."""
         self.assertEqual(i18n.twtranslate('en', 'test-semi-localized'),
                          u'test-semi-localized EN')
         self.assertEqual(i18n.twtranslate('nl', 'test-semi-localized'),
@@ -161,6 +172,7 @@
                          u'test-semi-localized NL')
 
     def testNonLocalized(self):
+        """Test translating non localized entries."""
         self.assertEqual(i18n.twtranslate('en', 'test-non-localized'),
                          u'test-non-localized EN')
         self.assertEqual(i18n.twtranslate('fy', 'test-non-localized'),
@@ -171,6 +183,7 @@
                          u'test-non-localized EN')
 
     def testNoEnglish(self):
+        """Test translating into English with missing entry."""
         self.assertRaises(i18n.TranslationError, i18n.twtranslate,
                           'en', 'test-no-english')
 
@@ -234,6 +247,7 @@
             u'Robot: Changer seulement une page.')
 
     def testMultiple(self):
+        """Test using multiple plural entries."""
         self.assertEqual(
             i18n.twntranslate('de', 'test-multiple-plurals', 1)
             % {'action': u'Ändere', 'line': u'eine'},
@@ -304,6 +318,7 @@
                 u'Bot: Ändere elf Zeilen von mehreren Seiten.')
 
     def testAllParametersExist(self):
+        """Test that all parameters are required when using a dict."""
         with self.assertRaisesRegex(KeyError, repr(u'line')):
             # all parameters must be inside twntranslate
             self.assertEqual(
@@ -362,6 +377,7 @@
 
     @classmethod
     def setUpClass(cls):
+        """Verify that a translation does not yet exist."""
         if cls.code in i18n.twget_keys('pywikibot-enter-category-name'):
             raise unittest.SkipTest(
                 '%s has a translation for %s'
@@ -390,6 +406,7 @@
         self.output_text = text
 
     def setUp(self):
+        """Patch the output and input methods."""
         super(MissingPackageTestCase, self).setUp()
         self.output_text = ''
         self.orig_raw_input = bot.ui._raw_input
@@ -398,6 +415,7 @@
         bot.ui.output = self._capture_output
 
     def tearDown(self):
+        """Restore the output and input methods."""
         bot.ui._raw_input = self.orig_raw_input
         bot.ui.output = self.orig_output
         super(MissingPackageTestCase, self).tearDown()
diff --git a/tests/isbn_tests.py b/tests/isbn_tests.py
index 57325f9..bed1615 100644
--- a/tests/isbn_tests.py
+++ b/tests/isbn_tests.py
@@ -40,6 +40,7 @@
         self.assertEqual(text, ' ISBN 978-0-9752298-0-4 ')
 
     def test_invalid_isbn(self):
+        """Test that it'll fail when the ISBN is invalid."""
         cc = CosmeticChangesToolkit(self.site, namespace=0)
 
         self.assertRaises(Exception, cc.fix_ISBN, 'ISBN 0975229LOL')  # 
Invalid characters
@@ -48,6 +49,7 @@
         self.assertRaises(Exception, cc.fix_ISBN, 'ISBN 09752X9801')  # X in 
the middle
 
     def test_ignore_invalid_isbn(self):
+        """Test fixing ISBN numbers with an invalid ISBN."""
         cc = CosmeticChangesToolkit(self.site, namespace=0, 
ignore=CANCEL_MATCH)
 
         text = cc.fix_ISBN(' ISBN 0975229LOL ISBN 9780975229804 ')
@@ -139,15 +141,18 @@
     write = True
 
     def setUp(self):
+        """Patch the Bot class to avoid an actual write."""
         self._original_userPut = Bot.userPut
         Bot.userPut = userPut_dummy
         super(TestIsbnBot, self).setUp()
 
     def tearDown(self):
+        """Unpatch the Bot class."""
         Bot.userPut = self._original_userPut
         super(TestIsbnBot, self).tearDown()
 
     def test_isbn(self):
+        """Test the ISBN bot."""
         site = self.get_site()
         p1 = pywikibot.Page(site, 'User:M4tx/IsbnTest')
         # Create the page if it does not exist
@@ -159,6 +164,7 @@
 
 
 def userPut_dummy(self, page, oldtext, newtext, **kwargs):
+    """Avoid that userPut writes."""
     TestIsbnBot.newtext = newtext
 
 
@@ -195,6 +201,7 @@
             % cls.__name__)
 
     def setUp(self):
+        """Patch Claim.setTarget and ItemPage.editEntity which write."""
         TestIsbnWikibaseBot._original_setTarget = Claim.setTarget
         Claim.setTarget = setTarget_dummy
         TestIsbnWikibaseBot._original_editEntity = ItemPage.editEntity
@@ -202,11 +209,13 @@
         super(TestIsbnWikibaseBot, self).setUp()
 
     def tearDown(self):
+        """Unpatch the dummy methods."""
         Claim.setTarget = TestIsbnWikibaseBot._original_setTarget
         ItemPage.editEntity = TestIsbnWikibaseBot._original_editEntity
         super(TestIsbnWikibaseBot, self).tearDown()
 
     def test_isbn(self):
+        """Test using the bot and wikibase."""
         main('-page:' + self.test_page_qid, '-always', '-format')
         self.assertEqual(self.setTarget_value, '0-9752298-0-X')
         main('-page:' + self.test_page_qid, '-always', '-to13')
@@ -214,11 +223,13 @@
 
 
 def setTarget_dummy(self, value):
+    """Avoid that setTarget writes."""
     TestIsbnWikibaseBot.setTarget_value = value
     TestIsbnWikibaseBot._original_setTarget(self, value)
 
 
 def editEntity_dummy(self, data=None, **kwargs):
+    """Avoid that editEntity writes."""
     pass
 
 if __name__ == "__main__":
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 1de1fa9..e407b72 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -107,6 +107,7 @@
     cached = True
 
     def test_interwiki_format(self):
+        """Test formatting interwiki links using Page instances."""
         interwikis = {
             'de': pywikibot.Page(pywikibot.Link('de:German', self.site)),
             'fr': pywikibot.Page(pywikibot.Link('fr:French', self.site))
@@ -126,22 +127,26 @@
                  % {'LS': config.LS})
 
     def test_category_format_raw(self):
+        """Test formatting categories as strings formatted as links."""
         self.assertEqual(self.catresult,
                          textlib.categoryFormat(['[[Category:Cat1]]',
                                                  '[[Category:Cat2]]'],
                                                 self.site))
 
     def test_category_format_bare(self):
+        """Test formatting categories as strings."""
         self.assertEqual(self.catresult,
                          textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
 
     def test_category_format_Category(self):
+        """Test formatting categories as Category instances."""
         data = [pywikibot.Category(self.site, 'Cat1'),
                 pywikibot.Category(self.site, 'Cat2')]
         self.assertEqual(self.catresult,
                          textlib.categoryFormat(data, self.site))
 
     def test_category_format_Page(self):
+        """Test formatting categories as Page instances."""
         data = [pywikibot.Page(self.site, 'Category:Cat1'),
                 pywikibot.Page(self.site, 'Category:Cat2')]
         self.assertEqual(self.catresult,
@@ -164,11 +169,13 @@
            % {'LS': config.LS})
 
     def test_standard_links(self):
+        """Test getting and replacing categories."""
         cats = textlib.getCategoryLinks(self.old, site=self.site)
         new = textlib.replaceCategoryLinks(self.old, cats, site=self.site)
         self.assertEqual(self.old, new)
 
     def test_adjoining_links(self):
+        """Test getting and replacing adjacent categories."""
         cats_std = textlib.getCategoryLinks(self.old, site=self.site)
         old = self.old.replace(config.LS, '')
         cats = textlib.getCategoryLinks(old, site=self.site)
@@ -238,6 +245,7 @@
     cached = True
 
     def test_templates(self):
+        """Test normal templates inside category links."""
         self.site = self.get_site()
         self.assertEqual(textlib.getCategoryLinks(
             '[[Category:{{P1|Foo}}]]', self.site),
@@ -569,6 +577,7 @@
 
     @classmethod
     def setUpClass(cls):
+        """Create a fake interwiki cache."""
         super(TestReplaceLinks, cls).setUpClass()
         # make APISite.interwiki work, as long as it doesn't call
         # _cache_interwikimap with force=True
@@ -797,6 +806,7 @@
     net = False
 
     def test_to_local(self):
+        """Test converting Arabic digits to local digits."""
         self.assertEqual(textlib.to_local_digits(299792458, 'en'), 299792458)
         self.assertEqual(
             textlib.to_local_digits(299792458, 'fa'), u"۲۹۹۷۹۲۴۵۸")
@@ -813,11 +823,13 @@
     """Test to verify the replacements with exceptions are done correctly."""
 
     def test_no_replace(self):
+        """Test replacing when the old text does not match."""
         self.assertEqual(textlib.replaceExcept('12345678', 'x', 'y', [],
                                                site=self.site),
                          '12345678')
 
     def test_simple_replace(self):
+        """Test replacing without regex."""
         self.assertEqual(textlib.replaceExcept('AxB', 'x', 'y', [],
                                                site=self.site),
                          'AyB')
@@ -829,6 +841,7 @@
                          'AyyyB')
 
     def test_regex_replace(self):
+        """Test replacing with a regex."""
         self.assertEqual(textlib.replaceExcept('A123B', r'\d', r'x', [],
                                                site=self.site),
                          'AxxxB')
@@ -867,6 +880,7 @@
             'A1x3B')
 
     def test_case_sensitive(self):
+        """Test replacing with different case sensitivity."""
         self.assertEqual(textlib.replaceExcept('AxB', 'x', 'y', [],
                                                caseInsensitive=False,
                                                site=self.site),
@@ -885,6 +899,7 @@
                          'AyB')
 
     def test_replace_with_marker(self):
+        """Test replacing with a marker."""
         self.assertEqual(textlib.replaceExcept('AxyxB', 'x', 'y', [],
                                                marker='.',
                                                site=self.site),
@@ -895,6 +910,7 @@
                          'AxyxB.')
 
     def test_overlapping_replace(self):
+        """Test replacing with and without overlap."""
         self.assertEqual(textlib.replaceExcept('1111', '11', '21', [],
                                                allowoverlap=False,
                                                site=self.site),
@@ -905,6 +921,7 @@
                          '2221')
 
     def test_replace_exception(self):
+        """Test replacing not inside a specific regex."""
         self.assertEqual(textlib.replaceExcept('123x123', '123', '000', [],
                                                site=self.site),
                          '000x000')
@@ -914,6 +931,7 @@
                          '000x123')
 
     def test_replace_tags(self):
+        """Test replacing not inside various tags."""
         self.assertEqual(textlib.replaceExcept('A <!-- x --> B', 'x', 'y',
                                                ['comment'], site=self.site),
                          'A <!-- x --> B')
@@ -977,6 +995,7 @@
                              '[[%s:x]]' % ns_name)
 
     def test_replace_tags_interwiki(self):
+        """Test replacing not inside interwiki links."""
         if 'es' not in self.site.family.langs or 'ey' in 
self.site.family.langs:
             raise unittest.SkipTest('family %s doesnt have languages'
                                     % self.site)
@@ -989,6 +1008,7 @@
                          '[[ey:y]]')  # "ex" is not a valid interwiki code
 
     def test_replace_template(self):
+        """Test replacing not inside templates."""
         template_sample = (r'a {{templatename '
                            r'    | accessdate={{Fecha|1993}} '
                            r'    |atitle=The [[real title]] }}')
diff --git a/tox.ini b/tox.ini
index 67b30f7..293106f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -125,6 +125,7 @@
     tests/__init__.py \
     tests/aspects.py \
     tests/utils.py \
+    tests/api_tests.py \
     tests/archivebot_tests.py \
     tests/basepage_tests.py \
     tests/bot_tests.py \
@@ -138,6 +139,8 @@
     tests/deletionbot_tests.py \
     tests/disambredir_tests.py \
     tests/djvu_tests.py \
+    tests/dry_api_tests.py \
+    tests/dry_site_tests.py \
     tests/edit_tests.py \
     tests/edit_failure_tests.py \
     tests/exceptions_tests.py \
@@ -147,8 +150,10 @@
     tests/flow_tests.py \
     tests/http_tests.py \
     tests/i18n/ \
+    tests/i18n_tests.py \
     tests/interwiki_graph_tests.py \
     tests/interwiki_link_tests.py \
+    tests/isbn_tests.py \
     tests/l10n_tests.py \
     tests/link_tests.py \
     tests/logentry_tests.py \
@@ -166,6 +171,7 @@
     tests/script_tests.py \
     tests/site_detect_tests.py \
     tests/tests_tests.py \
+    tests/textlib_tests.py \
     tests/timestamp_tests.py \
     tests/timestripper_tests.py \
     tests/thread_tests.py \

-- 
To view, visit https://gerrit.wikimedia.org/r/231968
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bfa6f9c63b08279477d8b4af77d1b99806a6ef9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to