[MediaWiki-commits] [Gerrit] [IMPROV] Add docstrings to various test modules - change (pywikibot/core)
jenkins-bot has submitted this change and it was merged. 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, 103 insertions(+), 1 deletion(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/api_tests.py b/tests/api_tests.py index 071be74..b898c4a 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
[MediaWiki-commits] [Gerrit] [IMPROV] Add docstrings to various test modules - change (pywikibot/core)
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."""