本文整理汇总了Python中test.test_support.is_resource_enabled函数的典型用法代码示例。如果您正苦于以下问题:Python is_resource_enabled函数的具体用法?Python is_resource_enabled怎么用?Python is_resource_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_resource_enabled函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_main
def test_main(verbose=False):
if skip_expected:
raise test_support.TestSkipped("No SSL support")
global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT
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")
if not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT):
raise test_support.TestFailed("Can't read certificate files!")
TESTPORT = test_support.find_unused_port()
if not TESTPORT:
raise test_support.TestFailed("Can't find open port to test servers on!")
tests = [BasicTests]
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)
test_support.run_unittest(*tests)
if _have_threads:
test_support.threading_cleanup(*thread_info)
开发者ID:Cinnz,项目名称:python,代码行数:29,代码来源:test_ssl.py
示例2: test_main
def test_main(verbose=False):
if skip_expected:
raise test_support.TestSkipped("No SSL support")
global CERTFILE, TESTPORT, SVN_PYTHON_ORG_ROOT_CERT
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")
if (not os.path.exists(CERTFILE) or
not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)):
raise test_support.TestFailed("Can't read certificate files!")
TESTPORT = findtestsocket(10025, 12000)
if not TESTPORT:
raise test_support.TestFailed("Can't find open port to test servers on!")
tests = [BasicTests]
if test_support.is_resource_enabled('network'):
tests.append(NetworkedTests)
if _have_threads:
if CERTFILE and test_support.is_resource_enabled('network'):
tests.append(ThreadedTests)
test_support.run_unittest(*tests)
开发者ID:18600597055,项目名称:hue,代码行数:29,代码来源:test_ssl.py
示例3: test_main
def test_main(arith=False, verbose=None):
""" Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py
"""
init()
global TEST_ALL
TEST_ALL = arith or is_resource_enabled('decimal')
test_classes = [
DecimalExplicitConstructionTest,
DecimalImplicitConstructionTest,
DecimalArithmeticOperatorsTest,
DecimalUseOfContextTest,
DecimalUsabilityTest,
DecimalPythonAPItests,
ContextAPItests,
DecimalTest,
WithStatementTest,
]
try:
run_unittest(*test_classes)
import decimal as DecimalModule
run_doctest(DecimalModule, verbose)
finally:
setcontext(ORIGINAL_CONTEXT)
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:29,代码来源:test_decimal.py
示例4: test_main
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)
开发者ID:jythontools,项目名称:jython,代码行数:26,代码来源:test_chdir.py
示例5: test_main
def test_main(verbose=None):
tests = (TrivialTests,
OpenerDirectorTests,
HandlerTests,
MiscTests)
if test_support.is_resource_enabled('network'):
tests += (NetworkTests,)
test_support.run_unittest(*tests)
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:8,代码来源:test_urllib2.py
示例6: test_main
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)
开发者ID:Daetalus,项目名称:pyston,代码行数:12,代码来源:test_imaplib.py
示例7: test_main
def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
""" Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource
is enabled in regrtest.py
"""
init()
global TEST_ALL, DEBUG
TEST_ALL = arith or is_resource_enabled("decimal")
DEBUG = debug
if todo_tests is None:
test_classes = [
DecimalExplicitConstructionTest,
DecimalImplicitConstructionTest,
DecimalArithmeticOperatorsTest,
DecimalFormatTest,
DecimalUseOfContextTest,
DecimalUsabilityTest,
DecimalPythonAPItests,
ContextAPItests,
DecimalTest,
WithStatementTest,
ContextFlags,
]
else:
test_classes = [DecimalTest]
# Dynamically build custom test definition for each file in the test
# directory and add the definitions to the DecimalTest class. This
# procedure insures that new files do not get skipped.
for filename in os.listdir(directory):
if ".decTest" not in filename or filename.startswith("."):
continue
head, tail = filename.split(".")
if todo_tests is not None and head not in todo_tests:
continue
tester = lambda self, f=filename: self.eval_file(directory + f)
setattr(DecimalTest, "test_" + head, tester)
del filename, head, tail, tester
try:
run_unittest(*test_classes)
if todo_tests is None:
import decimal as DecimalModule
run_doctest(DecimalModule, verbose)
finally:
setcontext(ORIGINAL_CONTEXT)
开发者ID:harry159821,项目名称:sl4a,代码行数:50,代码来源:test_decimal.py
示例8: test_no_leaking
def test_no_leaking(self):
# Make sure we leak no resources
if test_support.is_resource_enabled("subprocess") and not mswindows:
max_handles = 1026 # too much for most UNIX systems
else:
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")
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:test_subprocess.py
示例9: test_large_file_ops
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] in ("win", "os2") or sys.platform == "darwin":
if not test_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
f = io.open(test_support.TESTFN, "w+b", 0)
self.large_file_ops(f)
f.close()
f = io.open(test_support.TESTFN, "w+b")
self.large_file_ops(f)
f.close()
开发者ID:fabianonunes,项目名称:plone-4.1,代码行数:16,代码来源:test_io.py
示例10: test_main
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,
)
开发者ID:herenowcoder,项目名称:stackless,代码行数:16,代码来源:test_xpickle.py
示例11: test_main
def test_main():
if verbose:
print 'starting...'
# This displays the tokenization of tokenize_tests.py to stdout, and
# regrtest.py checks that this equals the expected output (in the
# test/output/ directory).
f = open(findfile('tokenize_tests' + os.extsep + 'txt'))
tokenize(f.readline)
f.close()
# Now run test_roundtrip() over tokenize_test.py too, and over all
# (if the "compiler" resource is enabled) or a small random sample (if
# "compiler" is not enabled) of the test*.py files.
f = findfile('tokenize_tests' + os.extsep + 'txt')
test_roundtrip(f)
testdir = os.path.dirname(f) or os.curdir
testfiles = glob.glob(testdir + os.sep + 'test*.py')
if not is_resource_enabled('compiler'):
testfiles = random.sample(testfiles, 10)
for f in testfiles:
test_roundtrip(f)
# Test detecton of IndentationError.
sampleBadText = """\
def foo():
bar
baz
"""
try:
for tok in generate_tokens(StringIO(sampleBadText).readline):
pass
except IndentationError:
pass
else:
raise TestFailed("Did not detect IndentationError:")
# Run the doctests in this module.
from test import test_tokenize # i.e., this module
from test.test_support import run_doctest
run_doctest(test_tokenize)
if verbose:
print 'finished'
开发者ID:B-Rich,项目名称:breve,代码行数:47,代码来源:test_tokenize.py
示例12: testSSLconnect
def testSSLconnect(self):
if not test_support.is_resource_enabled("network"):
return
s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE)
s.connect(("svn.python.org", 443))
c = s.getpeercert()
if c:
raise test_support.TestFailed("Peer cert %s shouldn't be here!")
s.close()
# this should fail because we have no verification certs
s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_REQUIRED)
try:
s.connect(("svn.python.org", 443))
except ssl.SSLError:
pass
finally:
s.close()
开发者ID:Cinnz,项目名称:python,代码行数:18,代码来源:test_ssl.py
示例13: test_main
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.append(ThreadedNetworkedTestsSSL)
tests.append(ThreadedNetworkedTests)
threadinfo = support.threading_setup()
support.run_unittest(*tests)
support.threading_cleanup(*threadinfo)
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:18,代码来源:test_imaplib.py
示例14: test_no_leaking
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")
开发者ID:babble,项目名称:babble,代码行数:18,代码来源:test_subprocess.py
示例15: test_random_files
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
开发者ID:billtsay,项目名称:win-demo-opcua,代码行数:19,代码来源:test_tokenize.py
示例16: run_compat_test
def run_compat_test(python_name):
return test_support.is_resource_enabled("xpickle") and have_python_version(python_name)
开发者ID:herenowcoder,项目名称:stackless,代码行数:2,代码来源:test_xpickle.py
示例17: CreationTestCase
"""Unit tests for socket timeout feature."""
import unittest
from test import test_support
# This requires the 'network' resource as given on the regrtest command line.
skip_expected = not test_support.is_resource_enabled('network')
import time
import socket
class CreationTestCase(unittest.TestCase):
"""Test case for socket.gettimeout() and socket.settimeout()"""
def setUp(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def tearDown(self):
self.sock.close()
def testObjectCreation(self):
# Test Socket creation
self.assertEqual(self.sock.gettimeout(), None,
"timeout not disabled by default")
def testFloatReturnValue(self):
# Test return value of gettimeout()
self.sock.settimeout(7.345)
self.assertEqual(self.sock.gettimeout(), 7.345)
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:30,代码来源:test_timeout.py
注:本文中的test.test_support.is_resource_enabled函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论