本文整理匯總了Python中test.test_support.ResourceDenied方法的典型用法代碼示例。如果您正苦於以下問題:Python test_support.ResourceDenied方法的具體用法?Python test_support.ResourceDenied怎麽用?Python test_support.ResourceDenied使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test.test_support
的用法示例。
在下文中一共展示了test_support.ResourceDenied方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: runtest_inner
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import ResourceDenied [as 別名]
def runtest_inner(test, verbose, quiet, huntrleaks=False):
test_support.unload(test)
if verbose:
capture_stdout = None
else:
capture_stdout = StringIO.StringIO()
test_time = 0.0
refleak = False # True if the test leaked references.
try:
save_stdout = sys.stdout
try:
if capture_stdout:
sys.stdout = capture_stdout
if test.startswith('test.'):
abstest = test
else:
# Always import it from the test package
abstest = 'test.' + test
with saved_test_environment(test, verbose, quiet) as environment:
start_time = time.time()
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, test)
# Old tests run to completion simply as a side-effect of
# being imported. For tests based on unittest or doctest,
# explicitly invoke their test_main() function (if it exists).
indirect_test = getattr(the_module, "test_main", None)
if indirect_test is not None:
indirect_test()
if huntrleaks:
refleak = dash_R(the_module, test, indirect_test,
huntrleaks)
test_time = time.time() - start_time
finally:
sys.stdout = save_stdout
except test_support.ResourceDenied, msg:
if not quiet:
print test, "skipped --", msg
sys.stdout.flush()
return RESOURCE_DENIED, test_time
示例2: runtest_inner
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import ResourceDenied [as 別名]
def runtest_inner(test, generate, verbose, quiet,
testdir=None, huntrleaks=False, junit_xml_dir=None):
test_support.unload(test)
if not testdir:
testdir = findtestdir()
outputdir = os.path.join(testdir, "output")
outputfile = os.path.join(outputdir, test)
if verbose:
cfp = None
else:
cfp = cStringIO.StringIO()
try:
save_stdout = sys.stdout
if junit_xml_dir:
from test.junit_xml import Tee, write_direct_test
indirect_test = None
save_stderr = sys.stderr
sys.stdout = stdout = Tee(sys.stdout)
sys.stderr = stderr = Tee(sys.stderr)
try:
if cfp:
sys.stdout = cfp
print test # Output file starts with test name
if test.startswith('test.'):
abstest = test
else:
# Always import it from the test package
abstest = 'test.' + test
start = time.time()
the_package = __import__(abstest, globals(), locals(), [])
the_module = getattr(the_package, test)
# Most tests run to completion simply as a side-effect of
# being imported. For the benefit of tests that can't run
# that way (like test_threaded_import), explicitly invoke
# their test_main() function (if it exists).
indirect_test = getattr(the_module, "test_main", None)
if indirect_test is not None:
indirect_test()
elif junit_xml_dir:
write_direct_test(junit_xml_dir, abstest, time.time() - start,
stdout=stdout.getvalue(),
stderr=stderr.getvalue())
if huntrleaks:
dash_R(the_module, test, indirect_test, huntrleaks)
finally:
sys.stdout = save_stdout
if junit_xml_dir:
sys.stderr = save_stderr
except test_support.ResourceDenied, msg:
if not quiet:
print test, "skipped --", msg
sys.stdout.flush()
if junit_xml_dir:
write_direct_test(junit_xml_dir, abstest, time.time() - start,
'skipped', sys.exc_info(),
stdout=stdout.getvalue(),
stderr=stderr.getvalue())
return -2