]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
if the test is run directly (__name__ == "__main__") don't actually require
authorSkip Montanaro <skip@pobox.com>
Thu, 24 Apr 2003 19:06:57 +0000 (19:06 +0000)
committerSkip Montanaro <skip@pobox.com>
Thu, 24 Apr 2003 19:06:57 +0000 (19:06 +0000)
particular resources

Lib/test/test_support.py

index 776341dfcc93280b92bbae05613422efb0ea3c4b..c61e194f57a22d29b72d911df06a79c0af60a017 100644 (file)
@@ -62,6 +62,10 @@ def is_resource_enabled(resource):
     return use_resources is not None and resource in use_resources
 
 def requires(resource, msg=None):
+    # see if the caller's module is __main__ - if so, treat as if
+    # the resource was set
+    if sys._getframe().f_back.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