diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-03-01 14:47:50 +0200 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-03-01 14:47:50 +0200 |
commit | 90ed202c9e3d04d8a64f9be221b7678f6dbb2fc6 (patch) | |
tree | 36cb39be9d1963ff5c6f64ba81557fccb577edd0 /Lib/unittest/loader.py | |
parent | 6d51e981bef7a7db65c80f7580fb700b08ae9d22 (diff) | |
download | cpython-90ed202c9e3d04d8a64f9be221b7678f6dbb2fc6.tar.gz |
#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.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py index a5ac737fc2..2077fa3cdb 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: |