Python test.test_support.is_resource_enabled() Examples
The following are 30
code examples of test.test_support.is_resource_enabled().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.test_support
, or try the search function
.
Example #1
Source File: test_imaplib.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #2
Source File: test_imaplib.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #3
Source File: test_xpickle.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_main(): if not test_support.is_resource_enabled("xpickle"): print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." sys.stderr.flush() test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle, CPicklePython24Compat, CPicklePython25Compat, CPicklePython26Compat, PicklePython24Compat, PicklePython25Compat, PicklePython26Compat, )
Example #4
Source File: test_io.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_large_file_ops(self): # On Windows and Mac OSX this test comsumes large resources; It takes # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if not support.is_resource_enabled("largefile"): skip_platform = None # Cases in which to skip this test if sys.platform[:3] == 'win' or sys.platform == 'darwin': skip_platform = sys.platform; elif sys.platform[:4] == "java": # Jython cases in which to skip this test if os._name == "nt": skip_platform = 'Jython + ' + os._name; if skip_platform: print("\nTesting large file ops skipped on %s." % skip_platform, file=sys.stderr) print("It requires %d bytes and a long time." % self.LARGE, file=sys.stderr) print("Use 'regrtest.py -u largefile test_io' to run it.", file=sys.stderr) return with self.open(support.TESTFN, "w+b", 0) as f: self.large_file_ops(f) with self.open(support.TESTFN, "w+b") as f: self.large_file_ops(f)
Example #5
Source File: test_imaplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #6
Source File: test_xpickle.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_main(): if not test_support.is_resource_enabled("xpickle"): print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." sys.stderr.flush() test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle, CPicklePython24Compat, CPicklePython25Compat, CPicklePython26Compat, PicklePython24Compat, PicklePython25Compat, PicklePython26Compat, )
Example #7
Source File: test_io.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_large_file_ops(self): # On Windows and Mac OSX this test comsumes large resources; It takes # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if not support.is_resource_enabled("largefile"): skip_platform = None # Cases in which to skip this test if sys.platform[:3] == 'win' or sys.platform == 'darwin': skip_platform = sys.platform; elif sys.platform[:4] == "java": # Jython cases in which to skip this test if os._name == "nt": skip_platform = 'Jython + ' + os._name; if skip_platform: print("\nTesting large file ops skipped on %s." % skip_platform, file=sys.stderr) print("It requires %d bytes and a long time." % self.LARGE, file=sys.stderr) print("Use 'regrtest.py -u largefile test_io' to run it.", file=sys.stderr) return with self.open(support.TESTFN, "w+b", 0) as f: self.large_file_ops(f) with self.open(support.TESTFN, "w+b") as f: self.large_file_ops(f)
Example #8
Source File: test_chdir.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_main(): tests = [ChdirTestCase, ImportTestCase, ImportPackageTestCase, ZipimportTestCase, PyCompileTestCase, ExecfileTestCase, ExecfileTracebackTestCase, ListdirTestCase, DirsTestCase, FilesTestCase, SymlinkTestCase] if WINDOWS: tests.append(WindowsChdirTestCase) if test_support.is_jython: tests.extend((ImportJavaClassTestCase, ImportJarTestCase)) if test_support.is_resource_enabled('subprocess'): tests.append(SubprocessTestCase) test_support.run_unittest(*tests)
Example #9
Source File: test_subprocess.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_no_leaking(self): # Make sure we leak no resources if not hasattr(test_support, "is_resource_enabled") \ or test_support.is_resource_enabled("subprocess") and not mswindows \ and not jython: max_handles = 1026 # too much for most UNIX systems else: # Settle for 65 on jython: spawning jython processes takes a # long time max_handles = 65 for i in range(max_handles): p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) data = p.communicate("lime")[0] self.assertEqual(data, "lime")
Example #10
Source File: test_imaplib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #11
Source File: test_xpickle.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_main(): if not test_support.is_resource_enabled("xpickle"): print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." sys.stderr.flush() test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle, CPicklePython24Compat, CPicklePython25Compat, CPicklePython26Compat, PicklePython24Compat, PicklePython25Compat, PicklePython26Compat, )
Example #12
Source File: test_imaplib.py From oss-ftp with MIT License | 6 votes |
def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): if ssl: global CERTFILE CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") tests.extend([ ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, RemoteIMAPTest, RemoteIMAP_SSLTest, ]) support.run_unittest(*tests)
Example #13
Source File: test_tokenize.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_random_files(self): # Test roundtrip on random python modules. # pass the '-ucpu' option to process the full directory. import glob, random fn = test_support.findfile("tokenize_tests" + os.extsep + "txt") tempdir = os.path.dirname(fn) or os.curdir testfiles = glob.glob(os.path.join(tempdir, "test*.py")) if not test_support.is_resource_enabled("cpu"): testfiles = random.sample(testfiles, 10) for testfile in testfiles: try: with open(testfile, 'rb') as f: self.check_roundtrip(f) except: print "Roundtrip failed for file %s" % testfile raise
Example #14
Source File: test_xpickle.py From oss-ftp with MIT License | 6 votes |
def test_main(): if not test_support.is_resource_enabled("xpickle"): print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." sys.stderr.flush() test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle, CPicklePython24Compat, CPicklePython25Compat, CPicklePython26Compat, PicklePython24Compat, PicklePython25Compat, PicklePython26Compat, )
Example #15
Source File: test_io.py From BinderFilter with MIT License | 6 votes |
def test_large_file_ops(self): # On Windows and Mac OSX this test comsumes large resources; It takes # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. if sys.platform[:3] == 'win' or sys.platform == 'darwin': if not support.is_resource_enabled("largefile"): print("\nTesting large file ops skipped on %s." % sys.platform, file=sys.stderr) print("It requires %d bytes and a long time." % self.LARGE, file=sys.stderr) print("Use 'regrtest.py -u largefile test_io' to run it.", file=sys.stderr) return with self.open(support.TESTFN, "w+b", 0) as f: self.large_file_ops(f) with self.open(support.TESTFN, "w+b") as f: self.large_file_ops(f)
Example #16
Source File: test_ssl.py From BinderFilter with MIT License | 6 votes |
def test_ciphers(self): if not test_support.is_resource_enabled('network'): return remote = ("svn.python.org", 443) with test_support.transient_internet(remote[0]): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") s.connect(remote) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") s.connect(remote) # Error checking occurs when connecting, because the SSL context # isn't created before. s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx") with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): s.connect(remote)
Example #17
Source File: test_xpickle.py From BinderFilter with MIT License | 6 votes |
def test_main(): if not test_support.is_resource_enabled("xpickle"): print >>sys.stderr, "test_xpickle -- skipping backwards compat tests." print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them." sys.stderr.flush() test_support.run_unittest( DumpCPickle_LoadPickle, DumpPickle_LoadCPickle, CPicklePython24Compat, CPicklePython25Compat, CPicklePython26Compat, PicklePython24Compat, PicklePython25Compat, PicklePython26Compat, )
Example #18
Source File: test_chdir.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_main(): tests = [ ChdirTestCase, ImportTestCase, ImportPackageTestCase, ZipimportTestCase, PyCompileTestCase, ExecfileTestCase, ExecfileTracebackTestCase, ListdirTestCase, DirsTestCase, FilesTestCase, SymlinkTestCase ] if WINDOWS: tests.append(WindowsChdirTestCase) tests.remove(SymlinkTestCase) # os.symlink ... Availability: Unix. if test_support.is_jython: tests.extend((ImportJavaClassTestCase, ImportJarTestCase)) if test_support.is_resource_enabled('subprocess'): tests.append(SubprocessTestCase) test_support.run_unittest(*tests)
Example #19
Source File: test_xpickle.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def run_compat_test(python_name): return (test_support.is_resource_enabled("xpickle") and have_python_version(python_name)) # Test backwards compatibility with Python 2.4.
Example #20
Source File: test_chdir.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_main(): tests = [ ChdirTestCase, ImportTestCase, ImportPackageTestCase, ZipimportTestCase, PyCompileTestCase, ExecfileTestCase, ExecfileTracebackTestCase, ListdirTestCase, DirsTestCase, FilesTestCase, SymlinkTestCase ] if WINDOWS: tests.append(WindowsChdirTestCase) tests.remove(SymlinkTestCase) # os.symlink ... Availability: Unix. if test_support.is_jython: tests.extend((ImportJavaClassTestCase, ImportJarTestCase)) if test_support.is_resource_enabled('subprocess'): tests.append(SubprocessTestCase) test_support.run_unittest(*tests)
Example #21
Source File: test_xpickle.py From BinderFilter with MIT License | 5 votes |
def run_compat_test(python_name): return (test_support.is_resource_enabled("xpickle") and have_python_version(python_name)) # Test backwards compatibility with Python 2.4.
Example #22
Source File: test_xpickle.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def run_compat_test(python_name): return (test_support.is_resource_enabled("xpickle") and have_python_version(python_name)) # Test backwards compatibility with Python 2.4.
Example #23
Source File: test_ssl.py From BinderFilter with MIT License | 5 votes |
def test_main(verbose=False): global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.pem") NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nokia.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or not os.path.exists(NOKIACERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests, BasicSocketTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) try: test_support.run_unittest(*tests) finally: if _have_threads: test_support.threading_cleanup(*thread_info)
Example #24
Source File: test_xpickle.py From oss-ftp with MIT License | 5 votes |
def run_compat_test(python_name): return (test_support.is_resource_enabled("xpickle") and have_python_version(python_name)) # Test backwards compatibility with Python 2.4.
Example #25
Source File: test_ssl.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_main(verbose=False): global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.pem") NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nokia.pem") NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nullbytecert.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or not os.path.exists(NOKIACERT) or not os.path.exists(NULLBYTECERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests, BasicSocketTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) try: test_support.run_unittest(*tests) finally: if _have_threads: test_support.threading_cleanup(*thread_info)
Example #26
Source File: test_xpickle.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def run_compat_test(python_name): return (test_support.is_resource_enabled("xpickle") and have_python_version(python_name)) # Test backwards compatibility with Python 2.4.
Example #27
Source File: test_ssl.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 4 votes |
def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info)
Example #28
Source File: test_ssl.py From oss-ftp with MIT License | 4 votes |
def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info)
Example #29
Source File: test_ssl.py From CTFCrackTools with GNU General Public License v3.0 | 4 votes |
def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info)
Example #30
Source File: test_ssl.py From ironpython2 with Apache License 2.0 | 4 votes |
def test_main(verbose=False): if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break else: plat = repr(platform.platform()) print("test_ssl: testing with %r %r" % (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)) print(" under %s" % plat) print(" HAS_SNI = %r" % ssl.HAS_SNI) print(" OP_ALL = 0x%8x" % ssl.OP_ALL) try: print(" OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1) except AttributeError: pass for filename in [ CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE, ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY, SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA, BADCERT, BADKEY, EMPTYCERT]: if not os.path.exists(filename): raise support.TestFailed("Can't read certificate file %r" % filename) tests = [ContextTests, BasicTests, BasicSocketTests, SSLErrorTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info: tests.append(ThreadedTests) try: support.run_unittest(*tests) finally: if _have_threads: support.threading_cleanup(*thread_info)