本文整理汇总了Python中twisted.scripts.trial.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTrial
def runTrial(options):
"""Run Twisted trial based unittests, optionally with coverage.
:type options: :class:`~bridgedb.opt.TestOptions`
:param options: Parsed options for controlling the twisted.trial test
run. All unrecognised arguments after the known options will be passed
along to trial.
"""
from twisted.scripts import trial
# Insert 'trial' as the first system cmdline argument:
sys.argv = ['trial']
if options['coverage']:
try:
from coverage import coverage
except ImportError as ie:
print(ie.message)
else:
cov = coverage()
cov.start()
sys.argv.append('--coverage')
sys.argv.append('--reporter=bwverbose')
# Pass all arguments along to its options parser:
if 'test_args' in options:
for arg in options['test_args']:
sys.argv.append(arg)
# Tell trial to test the bridgedb package:
sys.argv.append('bridgedb.test')
trial.run()
if options['coverage']:
cov.stop()
cov.html_report('_trial_temp/coverage/')
示例2: test
def test(so, stdout, stderr):
petmail = os.path.abspath(sys.argv[0])
petmail_executable.append(petmail) # to run bin/petmail in a subprocess
from twisted.scripts import trial as twisted_trial
sys.argv = ["trial"] + so.test_args
twisted_trial.run() # this does not return
sys.exit(0) # just in case
示例3: run
def run():
"Run the Ibid test suite. Bit of a hack"
from twisted.scripts.trial import run
import sys
sys.argv.append("ibid")
run()
示例4: main
def main():
# init test cases
if len(sys.argv)>1:
test_case = ".".join([__file__.split('.')[0], sys.argv[1]])
else:
test_case = __file__.split('.')[0]
# launch trial
sys.argv = [sys.argv[0], test_case]
trial.run()
示例5: trial
def trial(config):
sys.argv = ['trial'] + config.trial_args
from allmydata._version import full_version
if full_version.endswith("-dirty"):
print >>sys.stderr
print >>sys.stderr, "WARNING: the source tree has been modified since the last commit."
print >>sys.stderr, "(It is usually preferable to commit, then test, then amend the commit(s)"
print >>sys.stderr, "if the tests fail.)"
print >>sys.stderr
# This does not return.
twisted_trial.run()
示例6: test_debuggerNotFound
def test_debuggerNotFound(self):
"""
When a debugger is not found, an error message is printed to the user.
"""
def _makeRunner(*args, **kwargs):
raise trial._DebuggerNotFound('foo')
self.patch(trial, "_makeRunner", _makeRunner)
try:
trial.run()
except SystemExit as e:
self.assertIn("foo", str(e))
else:
self.fail("Should have exited due to non-existent debugger!")
示例7: egg_test_runner
def egg_test_runner():
"""
Test collector and runner for setup.py test
"""
from twisted.scripts.trial import run
original_args = list(sys.argv)
sys.argv = ["", "resilience"]
try:
return run()
finally:
sys.argv = original_args
示例8: _run
def _run(self, test_loc):
"""
Executes the test step.
@param test_loc: location of test module
@type test_loc: str
"""
from twisted.scripts.trial import run
# remove the 'test' option from argv
sys.argv.remove('test')
# Mimick the trial script by adding the path as the last arg
sys.argv.append(test_loc)
# Add the current dir to path and pull it all together
sys.path.insert(0, os.path.curdir)
sys.path[:] = map(os.path.abspath, sys.path)
# GO!
run()
示例9: _run
def _run(self, test_loc):
"""
Executes the test step.
@param test_loc: location of test module
@type test_loc: str
"""
from twisted.scripts.trial import run
# Mimick the trial script by adding the path as the last arg
sys.argv.append(test_loc)
# No superuser should execute tests
if hasattr(os, "getuid") and os.getuid() == 0:
raise SystemExit('Do not test as a superuser! Exiting ...')
# Add the current dir to path and pull it all together
sys.path.insert(0, os.path.curdir)
sys.path[:] = map(os.path.abspath, sys.path)
# GO!
run()
示例10: run_trial
def run_trial():
from twisted.python import modules
# We monkey patch PythonModule in order to avoid tests inside namespace packages
# being run multiple times (see http://twistedmatrix.com/trac/ticket/5030)
PythonModule = modules.PythonModule
class PatchedPythonModule(PythonModule):
def walkModules(self, *a, **kw):
yielded = set()
# calling super on PythonModule instead of PatchedPythonModule, since we're monkey patching PythonModule
for module in super(PythonModule, self).walkModules(*a, **kw):
if module.name in yielded:
continue
yielded.add(module.name)
yield module
modules.PythonModule = PatchedPythonModule
from twisted.scripts.trial import run
run()
示例11: run
# This is a tiny helper module, to let "python -m allmydata.test.run_trial
# ARGS" does the same thing as running "trial ARGS" (unfortunately
# twisted/scripts/trial.py does not have a '__name__=="__main__"' clause).
#
# This makes it easier to run trial under coverage from tox:
# * "coverage run trial ARGS" is how you'd usually do it
# * but "trial" must be the one in tox's virtualenv
# * "coverage run `which trial` ARGS" works from a shell
# * but tox doesn't use a shell
# So use:
# "coverage run -m allmydata.test.run_trial ARGS"
from twisted.scripts.trial import run
run()
示例12: test_outbind
@defer.inlineCallbacks
def test_outbind(self):
client = SMPPClientReceiver(self.config, self.msgHandler)
smpp = yield client.connect()
yield smpp.getDisconnectedDeferred()
class SMPPClientServiceBindTimeoutTestCase(SimulatorTestCase):
configArgs = {
'sessionInitTimerSecs': 0.1,
}
def test_bind_transmitter_timeout(self):
client = SMPPClientTransmitter(self.config)
svc = SMPPClientService(client)
stopDeferred = svc.getStopDeferred()
startDeferred = svc.startService()
return defer.DeferredList([
self.assertFailure(startDeferred, SMPPSessionInitTimoutError),
self.assertFailure(stopDeferred, SMPPSessionInitTimoutError),
])
if __name__ == '__main__':
observer = log.PythonLoggingObserver()
observer.start()
logging.basicConfig(level=logging.DEBUG)
import sys
from twisted.scripts import trial
sys.argv.extend([sys.argv[0]])
trial.run()
示例13: trial
def trial(config):
sys.argv = ['trial'] + config.trial_args
# This does not return.
twisted_trial.run()
示例14: open
from twisted.scripts import trial
with open(".py3.notworking.txt", "r") as f:
not_working_list = f.read().splitlines()
# Get a list of all the tests by using "trial -n"
trial_output = subprocess.check_output(
"trial -n --reporter=bwverbose buildbot.test | "
"awk '/OK/ {print $1}'", shell=True)
trial_output = trial_output.decode("utf-8")
tests = trial_output.splitlines()
# Filter out the tests which are not working
for test in not_working_list:
try:
tests.remove(test)
except ValueError as e:
print("FAILED TO REMOVE ", test, type(test))
print("\n\nRunning tests with:\n\n", sys.version, "\n\n")
# Run the tests. To avoid "Argument list too long"
# errors, invoke twisted.scripts.trial.run() directly
# instead of invoking the trial script.
sys.argv[0] = "trial"
sys.argv.append("--reporter=bwverbose")
sys.argv += tests
sys.exit(trial.run())
示例15: run
def run(self):
import sys
from twisted.scripts import trial
sys.argv = ["trial", "--rterrors", "foolscap.test"]
trial.run() # does not return