jenkins-bot has submitted this change and it was merged.
Change subject: tests/aspects: Skip setUpClass if TestCase skipped
......................................................................
tests/aspects: Skip setUpClass if TestCase skipped
The class IndexPageTestCase earlier checked for bs4 as a
class decorator. But that check doesn't seem to work and is
a known bug in nosetests. We now modify setUpClass() to also
be skipped if the class is supposed to be skipped.
Bug: T129965
Change-Id: Iec2f706aa832f7bd20e56fbc3427e8f315499591
---
M tests/aspects.py
1 file changed, 11 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 5b2670a..e9a8788 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -328,8 +328,17 @@
except ImportError:
missing += [required_module]
if missing:
- return unittest.skip('{0} not installed'.format(
- ', '.join(missing)))(obj)
+ skip_decorator = unittest.skip('{0} not installed'.format(
+ ', '.join(missing)))
+ if (inspect.isclass(obj) and issubclass(obj, TestCaseBase) and
+ 'nose' in sys.modules.keys()):
+ # There is a known bug in nosetests which causes setUpClass()
+ # to be called even if the unittest class is skipped.
+ # Here, we decorate setUpClass() as a patch to skip it
+ # because of the missing modules too.
+ # Upstream report:
https://github.com/nose-devs/nose/issues/946
+ obj.setUpClass = classmethod(skip_decorator(lambda cls: None))
+ return skip_decorator(obj)
else:
return obj
--
To view, visit
https://gerrit.wikimedia.org/r/277465
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec2f706aa832f7bd20e56fbc3427e8f315499591
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: AbdealiJK <abdealikothari(a)gmail.com>
Gerrit-Reviewer: AbdealiJK <abdealikothari(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>