jenkins-bot has submitted this change and it was merged.
Change subject: Add general need_version tests ......................................................................
Add general need_version tests
Instead of re-enabling the tests for APISite.has_extension (and APISite.hasExtension) it adds a general test suite for site.need_version.
Change-Id: I1a156757b4e67a7db43320e4ad451414ebb5746f --- M tests/dry_site_tests.py M tests/site_tests.py 2 files changed, 29 insertions(+), 5 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py index ebea4ce..359f045 100644 --- a/tests/dry_site_tests.py +++ b/tests/dry_site_tests.py @@ -8,7 +8,7 @@ #
import pywikibot -from pywikibot.site import must_be +from pywikibot.site import must_be, need_version
from tests.utils import unittest, NoSiteTestCase, DummySiteinfo
@@ -108,5 +108,33 @@ kwargs = {'i': 'j', 'k': 'l'} self.assertRaises(pywikibot.NoSuchSite, self.call_this_user_req_function, args, kwargs)
+ +class TestNeedVersion(NoSiteTestCase): + """Test cases for the must_be decorator.""" + + # Implemented without setUpClass(cls) and global variables as objects + # were not completely disposed and recreated but retained 'memory' + def setUp(self): + super(TestNeedVersion, self).setUp() + self.version = lambda: "1.13" + + @need_version("1.14") + def too_new(self): + return True + + @need_version("1.13") + def old_enough(self): + return True + + @need_version("1.12") + def older(self): + return True + + def testNeedVersion(self): + self.assertRaises(NotImplementedError, self.too_new) + self.assertTrue(self.old_enough()) + self.assertTrue(self.older()) + + if __name__ == '__main__': unittest.main() diff --git a/tests/site_tests.py b/tests/site_tests.py index de281f0..63b1f48 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -987,10 +987,6 @@
self.assertFalse(mysite.has_extension('ThisExtensionDoesNotExist'))
- # test behavior for sites that do not report extensions - # TODO: Simulate a version to old to support this - # self.assertRaises(NotImplementedError, mysite.has_extension, ('anything')) - def test_API_limits_with_site_methods(self): # test step/total parameters for different sitemethods mypage = pywikibot.Page(mysite, 'Albert Einstein')
pywikibot-commits@lists.wikimedia.org