/usr/share/pyshared/nevow/scripts/nit.py is in python-nevow 0.10.0-4build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # -*- test-case-name: nevow.test.test_nit -*-
# Copyright (c) 2008 Divmod. See LICENSE for details.
"""
Implementation of the command line I{nit} tool
"""
import sys
from twisted.python.log import startLogging
from twisted.python.usage import UsageError, Options
from twisted.internet import reactor
from nevow.appserver import NevowSite
from nevow.livetrial.runner import TestFrameworkRoot
from nevow.livetrial.testcase import TestLoader, TestSuite
class NitOptions(Options):
optParameters = [
('port', None, '8080',
'Specify the TCP port to which to bind the test server')]
def parseArgs(self, *args):
self['testmodules'] = args
def postOptions(self):
self['port'] = int(self['port'])
def _getSuite(modules):
"""
Given an iterable of Python modules, return a nit test suite which
contains all the tests in those modules.
"""
loader = TestLoader()
suite = TestSuite('root')
for module in modules:
suite.addTest(loader.loadByName(module, True))
return suite
def run():
"""
Parse nit options from the command line and start a nit server.
"""
config = NitOptions()
try:
config.parseOptions()
except UsageError, ue:
raise SystemExit("%s: %s" % (sys.argv[0], ue))
else:
if not config['testmodules']:
raise SystemExit("Specify at least one module name to test")
startLogging(sys.stdout)
suite = _getSuite(config['testmodules'])
site = NevowSite(TestFrameworkRoot(suite))
reactor.listenTCP(config['port'], site)
reactor.run()
|