diff options
author | Fred Drake <fdrake@acm.org> | 2003-02-03 15:19:30 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2003-02-03 15:19:30 (GMT) |
commit | 9a0db07c2ffd4e4b3ae75d5820dc6b4152b3582b (patch) | |
tree | cdf94497d1ebdd3e08812ebbecb5533223a58bab /Lib | |
parent | 13b291021f0f9741423e41b94f04f931a442054c (diff) | |
download | cpython-9a0db07c2ffd4e4b3ae75d5820dc6b4152b3582b.zip cpython-9a0db07c2ffd4e4b3ae75d5820dc6b4152b3582b.tar.gz cpython-9a0db07c2ffd4e4b3ae75d5820dc6b4152b3582b.tar.bz2 |
test_support.requires(): Instead of raising TestSkipped, raise a new
exception, ResourceDenied. This is used to distinguish between tests that
are skipped for other reasons (platform support, missing data, etc.) from
those that are skipped because a "resource" has not been enabled. This
prevents those tests from being reported as unexpected skips for the
platform; those should only be considered unexpected skips if the resource
were enabled.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/test/regrtest.py | 10 | ||||
-rw-r--r-- | Lib/test/test_support.py | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 8e3a122..cc33439 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -196,6 +196,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, good = [] bad = [] skipped = [] + resource_denieds = [] if findleaks: try: @@ -263,6 +264,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, bad.append(test) else: skipped.append(test) + if ok == -2: + resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: @@ -299,7 +302,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, e = _ExpectedSkips() plat = sys.platform if e.isvalid(): - surprise = Set(skipped) - e.getexpected() + surprise = Set(skipped) - e.getexpected() - Set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" @@ -395,6 +398,11 @@ def runtest(test, generate, verbose, quiet, testdir = None): indirect_test() finally: sys.stdout = save_stdout + except test_support.ResourceDenied, msg: + if not quiet: + print test, "skipped --", msg + sys.stdout.flush() + return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 8169533..8ac3851 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -21,6 +21,14 @@ class TestSkipped(Error): TestFailed. """ +class ResourceDenied(TestSkipped): + """Test skipped because it requested a disallowed resource. + + This is raised when a test calls requires() for a resource that + has not be enabled. It is used to distinguish between expected + and unexpected skips. + """ + verbose = 1 # Flag set to 0 by regrtest.py use_resources = None # Flag set to [] by regrtest.py @@ -57,7 +65,7 @@ def requires(resource, msg=None): if not is_resource_enabled(resource): if msg is None: msg = "Use of the `%s' resource not enabled" % resource - raise TestSkipped(msg) + raise ResourceDenied(msg) FUZZ = 1e-6 |