mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
#16935: unittest now counts the module as skipped if it raises SkipTest, instead of counting it as an error. Patch by Zachary Ware.
This commit is contained in:
parent
dacb6858e8
commit
eae2b38948
4 changed files with 43 additions and 5 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue