本文整理汇总了Python中test.test_support.is_resource_enabled方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.is_resource_enabled方法的具体用法?Python test_support.is_resource_enabled怎么用?Python test_support.is_resource_enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.test_support
的用法示例。
在下文中一共展示了test_support.is_resource_enabled方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例2: test_random_files
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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
示例3: test_large_file_ops
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例4: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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,
)
示例5: test_ciphers
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例6: test_no_leaking
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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")
示例7: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例8: test_large_file_ops
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例9: run_compat_test
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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.
示例10: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例11: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例12: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例13: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)
示例14: test_main
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import is_resource_enabled [as 别名]
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)