jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/959178 )
Change subject: [IMPR] No longer drop site decorators for optimized codes ......................................................................
[IMPR] No longer drop site decorators for optimized codes
site decorators are useless with -O optimized code since https://gerrit.wikimedia.org/r/c/pywikibot/core/+/169788 but it might not be a good idea to ignore these decorators and let users guess the cause for failing scripts.
Bug: T74424 Change-Id: I9ab0dd60f3ae9f47b7462d07733fa42482102140 --- M tests/aspects.py M pywikibot/site/_decorators.py M tests/site_decorators_tests.py 3 files changed, 29 insertions(+), 32 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site/_decorators.py b/pywikibot/site/_decorators.py index d8fc123..975573b 100644 --- a/pywikibot/site/_decorators.py +++ b/pywikibot/site/_decorators.py @@ -1,6 +1,6 @@ """Decorators used by site models.""" # -# (C) Pywikibot team, 2008-2022 +# (C) Pywikibot team, 2008-2023 # # Distributed under the terms of the MIT license. # @@ -36,9 +36,6 @@
return fn(self, *args, **kwargs)
- if not __debug__: - return fn - manage_wrapping(callee, fn) return callee
@@ -60,9 +57,6 @@ .format(fn.__name__, extension)) return fn(self, *args, **kwargs)
- if not __debug__: - return fn - manage_wrapping(callee, fn) return callee
@@ -91,9 +85,6 @@ .format(self.user(), right)) return fn(self, *args, **kwargs)
- if not __debug__: - return fn - manage_wrapping(callee, fn) return callee
@@ -116,9 +107,6 @@ .format(fn.__name__, version)) return fn(self, *args, **kwargs)
- if not __debug__: - return fn - manage_wrapping(callee, fn)
return callee diff --git a/tests/aspects.py b/tests/aspects.py index baa5414..8bb0ec3 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -1362,21 +1362,7 @@ cls.override_default_site(pywikibot.Site('en', 'wikipedia'))
-class DebugOnlyTestCase(TestCase): - - """Test cases that only operate in debug mode.""" - - @classmethod - def setUpClass(cls): - """Set up test class.""" - if not __debug__: - raise unittest.SkipTest( - '{} is disabled when __debug__ is disabled.' - .format(cls.__name__)) - super().setUpClass() - - -class DeprecationTestCase(DebugOnlyTestCase, TestCase): +class DeprecationTestCase(TestCase):
"""Test cases for deprecation function in the tools module."""
@@ -1533,6 +1519,14 @@ 'expected warning filename {}; warning item: {}' .format(filename, item))
+ @classmethod + def setUpClass(cls): + """Only operate in debug mode.""" + if not __debug__: + raise unittest.SkipTest( + f'{cls.__name__} is disabled when __debug__ is disabled.') + super().setUpClass() + def setUp(self): """Set up unit test.""" super().setUp() diff --git a/tests/site_decorators_tests.py b/tests/site_decorators_tests.py index 3a4ce28..dfcfd3f 100755 --- a/tests/site_decorators_tests.py +++ b/tests/site_decorators_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Tests against a fake Site object.""" # -# (C) Pywikibot team, 2012-2022 +# (C) Pywikibot team, 2012-2023 # # Distributed under the terms of the MIT license. # @@ -10,10 +10,10 @@ from pywikibot.exceptions import UserRightsError from pywikibot.site._decorators import must_be, need_right, need_version from pywikibot.tools import deprecated -from tests.aspects import DebugOnlyTestCase, DeprecationTestCase +from tests.aspects import TestCase, DeprecationTestCase
-class TestMustBe(DebugOnlyTestCase): +class TestMustBe(TestCase):
"""Test cases for the must_be decorator."""
@@ -125,7 +125,7 @@ self.call_this_user_req_function(args, kwargs)
-class TestNeedRight(DebugOnlyTestCase): +class TestNeedRight(TestCase):
"""Test cases for the must_be decorator."""
pywikibot-commits@lists.wikimedia.org