def _main(): global __file__ # Remove regrtest.py's own directory from the module search path. Despite # the elimination of implicit relative imports, this is still needed to # ensure that submodules of the test package do not inappropriately appear # as top-level modules even when people (or buildbots!) invoke regrtest.py # directly instead of using the -m switch mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) i = len(sys.path) - 1 while i >= 0: if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] else: i -= 1 # findtestdir() gets the dirname out of __file__, so we have to make it # absolute before changing the working directory. # For example __file__ may be relative when running trace or profile. # See issue #9323. __file__ = os.path.abspath(__file__) # sanity check assert __file__ == os.path.abspath(sys.argv[0]) main()
def test_ssl(selenium): import platform import unittest import unittest.mock from test import libregrtest platform.platform(aliased=True) name = "test_ssl" ignore_tests = [ "*test_context_custom_class*", "*ThreadedTests*", "*ocket*", "test_verify_flags", "test_subclass", "test_lib_reason", ] try: with unittest.mock.patch( "test.support.socket_helper.bind_port", side_effect=unittest.SkipTest("nope!"), ): libregrtest.main([name], ignore_tests=ignore_tests, verbose=True, verbose3=True) except SystemExit as e: if e.code != 0: raise RuntimeError(f"Failed with code: {e.code}")
def _main(): global __file__ mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) i = len(sys.path) - 1 while i >= 0: if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] else: i -= 1 __file__ = os.path.abspath(__file__) assert __file__ == os.path.abspath(sys.argv[0]) main()
# This should be equivalent to running regrtest.py from the cmdline. # It can be especially handy if you're in an interactive shell, e.g., # from test import autotest. from test.libregrtest import main main()
"""Run Python's standard test suite using importlib.__import__. Tests known to fail because of assumptions that importlib (properly) invalidates are automatically skipped if the entire test suite is run. Otherwise all command-line options valid for test.regrtest are also valid for this script. """ import importlib import sys from test import libregrtest if __name__ == '__main__': __builtins__.__import__ = importlib.__import__ sys.path_importer_cache.clear() libregrtest.main(quiet=True, verbose2=True)
def main(tests=None, **kwargs): kwargs.setdefault("testdir", path) return libregrtest.main(tests=tests, **kwargs)