jenkins-bot has submitted this change and it was merged.

Change subject: Allow tests created by metaclass to be run
......................................................................


Allow tests created by metaclass to be run

Running individual test cases created by metaclasses
fails as unittest uses func.__name__ to find it, while
these test cases have the name of the wrapping method name.

  $ python -m unittest -v \
      tests.archivebot_tests.TestArchiveBot.test_wikipedia_vi
  ValueError: no such test method in
  <class 'tests.archivebot_tests.TestArchiveBot'>: test_archivebot

Change-Id: I793b0e1e92f88f7f734bb730cb8d811a2409f282
---
M tests/archivebot_tests.py
M tests/date_tests.py
M tests/script_tests.py
3 files changed, 3 insertions(+), 0 deletions(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index 8539ef3..765777c 100644
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -84,6 +84,7 @@
                 dct[test_name] = unittest.expectedFailure(test_method(code))
             else:
                 dct[test_name] = test_method(code)
+            dct[test_name].__name__ = test_name
         return type.__new__(cls, name, bases, dct)
 
 
diff --git a/tests/date_tests.py b/tests/date_tests.py
index 7d9a81f..5acf493 100644
--- a/tests/date_tests.py
+++ b/tests/date_tests.py
@@ -46,6 +46,7 @@
         for formatname in date.formats:
             test_name = "test_" + formatname
             dct[test_name] = test_method(formatname)
+            dct[test_name].__name__ = test_name
         return type.__new__(cls, name, bases, dct)
 
 
diff --git a/tests/script_tests.py b/tests/script_tests.py
index b229222..27a2ce3 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -230,6 +230,7 @@
                 dct[test_name] = unittest.expectedFailure(dct[test_name])
             dct[test_name].__doc__ = \
                 'Test running ' + script_name + ' without arguments.'
+            dct[test_name].__name__ = test_name
 
         return type.__new__(cls, name, bases, dct)
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I793b0e1e92f88f7f734bb730cb8d811a2409f282
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to