summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/loader.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-01 12:47:50 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-01 12:47:50 (GMT)
commiteae2b38948143a36d61bd2dabf07794613158efa (patch)
treeb300490eda37adefdd4dbfc566473967d91c9f90 /Lib/unittest/loader.py
parentdacb6858e88b6c4cb4659400e73b81e88864a7fa (diff)
downloadcpython-eae2b38948143a36d61bd2dabf07794613158efa.zip
cpython-eae2b38948143a36d61bd2dabf07794613158efa.tar.gz
cpython-eae2b38948143a36d61bd2dabf07794613158efa.tar.bz2
#16935: unittest now counts the module as skipped if it raises SkipTest, instead of counting it as an error. Patch by Zachary Ware.
Diffstat (limited to 'Lib/unittest/loader.py')
-rw-r--r--Lib/unittest/loader.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index a5ac737..2077fa3 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -34,6 +34,14 @@ def _make_failed_test(classname, methodname, exception, suiteClass):
TestClass = type(classname, (case.TestCase,), attrs)
return suiteClass((TestClass(methodname),))
+def _make_skipped_test(methodname, exception, suiteClass):
+ @case.skip(str(exception))
+ def testSkipped(self):
+ pass
+ attrs = {methodname: testSkipped}
+ TestClass = type("ModuleSkipped", (case.TestCase,), attrs)
+ return suiteClass((TestClass(methodname),))
+
def _jython_aware_splitext(path):
if path.lower().endswith('$py.class'):
return path[:-9]
@@ -259,6 +267,8 @@ class TestLoader(object):
name = self._get_name_from_path(full_path)
try:
module = self._get_module_from_name(name)
+ except case.SkipTest as e:
+ yield _make_skipped_test(name, e, self.suiteClass)
except:
yield _make_failed_import_test(name, self.suiteClass)
else: