summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index b814952..e1ee3f5 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -346,21 +346,17 @@ def _is_gui_available():
return _is_gui_available.result
def is_resource_enabled(resource):
- """Test whether a resource is enabled. Known resources are set by
- regrtest.py."""
- return use_resources is not None and resource in use_resources
+ """Test whether a resource is enabled.
-def requires(resource, msg=None):
- """Raise ResourceDenied if the specified resource is not available.
+ Known resources are set by regrtest.py. If not running under regrtest.py,
+ all resources are assumed enabled unless use_resources has been set.
+ """
+ return use_resources is None or resource in use_resources
- If the caller's module is __main__ then automatically return True. The
- possibility of False being returned occurs when regrtest.py is executing."""
+def requires(resource, msg=None):
+ """Raise ResourceDenied if the specified resource is not available."""
if resource == 'gui' and not _is_gui_available():
raise ResourceDenied(_is_gui_available.reason)
- # see if the caller's module is __main__ - if so, treat as if
- # the resource was set
- if sys._getframe(1).f_globals.get("__name__") == "__main__":
- return
if not is_resource_enabled(resource):
if msg is None:
msg = "Use of the `%s' resource not enabled" % resource