/usr/share/pyshared/pychecker2/test.py is in pychecker 0.8.19-11.
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 | import os
import sys
import unittest
import glob
def test(modules, verbosity):
for m in modules:
s = unittest.defaultTestLoader.loadTestsFromName(m)
result = unittest.TextTestRunner(verbosity=verbosity).run(s)
if not result.wasSuccessful():
return 1
return 0
def _modules(root):
modules = []
files = glob.glob(os.path.join(root, 'utest', '*.py'))
files.sort()
for fname in files:
fname = os.path.split(fname)[1] # remove path
module = 'pychecker2.utest.' + os.path.splitext(fname)[0]
if not module.endswith('_'): # ignore __init__
modules.append(module)
return modules
class Usage(Exception): pass
def main(args):
import getopt
verbosity = 1
try:
opts, files = getopt.getopt(args, 'v')
for opt, arg in opts:
if opt == '-v':
verbosity += 1
else:
raise Usage('unknown option ' + opt)
except getopt.GetoptError, detail:
raise Usage(str(detail))
root = os.path.dirname(os.path.realpath(sys.argv[0]))
pychecker2 = os.path.split(root)[0]
sys.path.append(pychecker2)
return test(_modules(root), verbosity)
if __name__ == '__main__':
try:
sys.exit(main(sys.argv[1:]))
except Usage, error:
err = sys.stderr
print >>err, "Error: " + str(error)
print >>err, "Usage: %s [-v]" % sys.argv[0]
sys.exit(1)
|