/usr/share/pyshared/pychecker2/TestSupport.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 56 57 | from pychecker2 import main
from pychecker2 import Options
import unittest
class WarningTester(unittest.TestCase):
def __init__(self, arg):
unittest.TestCase.__init__(self, arg)
self.options = Options.Options()
self.checklist = main.create_checklist(self.options)
self.argv = []
def check_warning(self, w, expected_line, expected_type, *expected_args):
warn_line, warn_type, warn_args = w
try:
self.assertEqual(warn_type, expected_type)
self.assertEqual(warn_line, expected_line)
self.assertEqual(len(warn_args), len(expected_args))
for i in range(len(expected_args)):
self.assertEqual(warn_args[i], expected_args[i])
except AssertionError: # help w/debugging
print warn_line, warn_type, warn_args
print expected_line, expected_type, expected_args
raise
def check_file(self, data):
import tempfile, os
fname = tempfile.mktemp()
fp = open(fname, 'wb')
try:
fp.write(data)
fp.close()
f, = self.options.process_options(self.argv + [fname])
self.checklist.check_file(f)
finally:
fp.close()
os.unlink(fname)
return f
def warning_file(self, f, line, warning, *args):
assert len(f.warnings) == 1, "Not just one warning:" + `f.warnings`
self.check_warning(f.warnings[0], line, warning, *args)
def warning(self, test, line, warning, *args):
test += '\n'
f = self.check_file(test)
self.warning_file(f, line, warning, *args)
def silent(self, test):
f = self.check_file(test)
if f.warnings:
print f.warnings
self.assertEqual(len(f.warnings), 0)
def setUp(self):
self.argv = []
|