jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] site_tests: Separate deprecated calls ......................................................................
[IMPROV] site_tests: Separate deprecated calls
The property `nocapitalize` and method `case()` of `APISite` have been deprecated but this wasn't tested. The test of the `case()` method has been moved and asserts the deprecation while a new test for `nocapitalize` has been added.
It also fixed the //instead// string of `case()` which was also adding //use//.
Change-Id: I0285fe24835c2e761092a0aa5379451c06ce10be --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 16 insertions(+), 3 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 3f3fe9f..665318b 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2411,7 +2411,7 @@ """Site information dict.""" return self._siteinfo
- @deprecated('use siteinfo or Namespace instance') + @deprecated('siteinfo or Namespace instance') def case(self): """Return this site's capitalization rule.""" # This is the global setting via $wgCapitalLinks, it is used whenever diff --git a/tests/site_tests.py b/tests/site_tests.py index 5b23525..2bd3e14 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -77,6 +77,17 @@
cached = True
+ def test_capitalization(self): + """Test that the case method is mirroring the siteinfo.""" + self.assertEqual(self.site.case(), self.site.siteinfo['case']) + self.assertOneDeprecationParts('pywikibot.site.BaseSite.case', + 'siteinfo or Namespace instance') + self.assertIs(self.site.nocapitalize, + self.site.siteinfo['case'] == 'case-sensitive') + self.assertOneDeprecationParts( + 'pywikibot.site.BaseSite.nocapitalize', + "APISite.siteinfo['case'] or Namespace.case == 'case-sensitive'") + def test_live_version(self): """Test live_version.""" mysite = self.get_site() @@ -224,7 +235,10 @@ self.assertIsInstance(dabcat, pywikibot.Category)
foo = unicode(pywikibot.Link("foo", source=mysite)) - self.assertEqual(foo, u"[[foo]]" if mysite.nocapitalize else u"[[Foo]]") + if self.site.namespaces[0].case == 'case-sensitive': + self.assertEqual(foo, '[[foo]]') + else: + self.assertEqual(foo, '[[Foo]]')
self.assertFalse(mysite.isInterwikiLink("foo")) self.assertIsInstance(mysite.redirectRegex().pattern, basestring) @@ -1895,7 +1909,6 @@ datetime.strptime(mysite.siteinfo['time'], '%Y-%m-%dT%H:%M:%SZ'), datetime) self.assertIn(mysite.siteinfo['case'], ["first-letter", "case-sensitive"]) - self.assertEqual(mysite.case(), mysite.siteinfo['case']) self.assertEqual(re.findall("$1", mysite.siteinfo['articlepath']), ["$1"])
def test_properties_with_defaults(self):
pywikibot-commits@lists.wikimedia.org