[MediaWiki-commits] [Gerrit] Allow @unittest.expectedFailure on all TestCase methods - change (pywikibot/core)

2014-10-15 Thread jenkins-bot (Code Review)
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; '

-- 
To view, visit https://gerrit.wikimedia.org/r/166374
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6d74af168e0bad93df65da2965daffa6b3951e0
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg jay...@gmail.com
Gerrit-Reviewer: John Vandenberg jay...@gmail.com
Gerrit-Reviewer: Ladsgroup ladsgr...@gmail.com
Gerrit-Reviewer: Merlijn van Deen valhall...@arctus.nl
Gerrit-Reviewer: XZise commodorefabia...@gmx.de
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Allow @unittest.expectedFailure on all TestCase methods - change (pywikibot/core)

2014-10-13 Thread John Vandenberg (Code Review)
John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/166374

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/74/166374/1

diff --git a/tests/aspects.py b/tests/aspects.py
index cbd870c..e62f384 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; '

-- 
To view, visit https://gerrit.wikimedia.org/r/166374
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6d74af168e0bad93df65da2965daffa6b3951e0
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg jay...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits