jenkins-bot has submitted this change and it was merged.
Change subject: Allow @unittest.expectedFailure on all TestCase methods ......................................................................
Allow @unittest.expectedFailure on all TestCase methods
TestCase allows test methods to be 'multi-site' tests, which will be re-run for each site in the TestCase sites matrix.
The metaclass has previously checked that the test method only has 1 or 2 arguments. @unittest.expectedFailure replaces the test method with a decorated version that appears as if it has zero arguments, due to the way decorators work. This change allows test methods with 0 arguments.
Change-Id: Ib6d74af168e0bad93df65da2965daffa6b3951e0 --- M tests/aspects.py 1 file changed, 9 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py index 08db133..7ff221f 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -340,6 +340,8 @@
return super(MetaTestCaseClass, cls).__new__(cls, name, bases, dct)
+ # The following section is only processed if the test uses sites. + if 'cacheinfo' in dct and dct['cacheinfo']: bases = tuple([CacheInfoMixin] + list(bases))
@@ -355,9 +357,16 @@ for test in tests: test_func = dct[test]
+ # method decorated with unittest.expectedFailure has no arguments + # so it is assumed to not be a multi-site test method. + if test_func.__code__.co_argcount == 0: + continue + + # a normal test method only accepts 'self' if test_func.__code__.co_argcount == 1: continue
+ # a multi-site test method only accepts 'self' and the site-key if test_func.__code__.co_argcount != 2: raise Exception( '%s: Test method %s must accept either 1 or 2 arguments; '
pywikibot-commits@lists.wikimedia.org