Issue #18492: Allow all resources when tests are not run by regrtest.py.

This changeset also includes cleanup allowed by this behavior change.
diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py
index 7ba191b..3fd3eb8 100644
--- a/Lib/test/test_codecmaps_hk.py
+++ b/Lib/test/test_codecmaps_hk.py
@@ -16,5 +16,4 @@
     test_support.run_unittest(__name__)
 
 if __name__ == "__main__":
-    test_support.use_resources = ['urlfetch']
     test_main()
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 87e8816..0902278 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -2271,7 +2271,7 @@
                                   "operation raises different flags depending on flags set: " +
                                   "expected %s, got %s" % (expected_flags, new_flags))
 
-def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
+def test_main(arith=None, verbose=None, todo_tests=None, debug=None):
     """ Execute the tests.
 
     Runs all arithmetic tests if arith is True or if the "decimal" resource
@@ -2280,7 +2280,7 @@
 
     init()
     global TEST_ALL, DEBUG
-    TEST_ALL = arith or is_resource_enabled('decimal')
+    TEST_ALL = arith if arith is not None else is_resource_enabled('decimal')
     DEBUG = debug
 
     if todo_tests is None:
diff --git a/Lib/test/test_idle.py b/Lib/test/test_idle.py
index 66dd8af..9bd38fe 100644
--- a/Lib/test/test_idle.py
+++ b/Lib/test/test_idle.py
@@ -17,8 +17,4 @@
     support.run_unittest(unittest.TestLoader().loadTestsFromModule(idletest))
 
 if __name__ == '__main__':
-    # Until unittest supports resources, we emulate regrtest's -ugui
-    # so loaded tests run the same as if textually present here.
-    # If any Idle test ever needs another resource, add it to the list.
-    support.use_resources = ['gui']  # use_resources is initially None
     unittest.main(verbosity=2, exit=False)
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 1beb39e..405b7ea 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -249,5 +249,4 @@
 
 
 if __name__ == "__main__":
-    support.use_resources = ['network']
     test_main()
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 @@
     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.
+
+    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
 
 def requires(resource, msg=None):
-    """Raise ResourceDenied if the specified resource is not available.
-
-    If the caller's module is __main__ then automatically return True.  The
-    possibility of False being returned occurs when regrtest.py is executing."""
+    """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
diff --git a/Lib/test/test_tk.py b/Lib/test/test_tk.py
index 56eef47..f3e264b 100644
--- a/Lib/test/test_tk.py
+++ b/Lib/test/test_tk.py
@@ -12,16 +12,10 @@
 with test_support.DirsOnSysPath(lib_tk_test):
     import runtktests
 
-def test_main(enable_gui=False):
-    if enable_gui:
-        if test_support.use_resources is None:
-            test_support.use_resources = ['gui']
-        elif 'gui' not in test_support.use_resources:
-            test_support.use_resources.append('gui')
-
+def test_main():
     with test_support.DirsOnSysPath(lib_tk_test):
         test_support.run_unittest(
             *runtktests.get_tests(text=False, packages=['test_tkinter']))
 
 if __name__ == '__main__':
-    test_main(enable_gui=True)
+    test_main()
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index 47ddefb..caa6930 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -22,13 +22,7 @@
     # assuming ttk is not available
     raise unittest.SkipTest("ttk not available: %s" % msg)
 
-def test_main(enable_gui=False):
-    if enable_gui:
-        if test_support.use_resources is None:
-            test_support.use_resources = ['gui']
-        elif 'gui' not in test_support.use_resources:
-            test_support.use_resources.append('gui')
-
+def test_main():
     with test_support.DirsOnSysPath(lib_tk_test):
         from test_ttk.support import get_tk_root
         try:
@@ -38,4 +32,4 @@
             get_tk_root().destroy()
 
 if __name__ == '__main__':
-    test_main(enable_gui=True)
+    test_main()