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.
This commit is contained in:
Fred Drake 2003-02-03 15:19:30 +00:00
parent 13b291021f
commit 9a0db07c2f
2 changed files with 18 additions and 2 deletions

View file

@ -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