[Pydev-cvs] org.python.pydev/PySrc/ThirdParty/logilab/pylint/test func_test_sample_config.py,1.3,1.4
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-04-19 14:39:53
|
Update of /cvsroot/pydev/org.python.pydev/PySrc/ThirdParty/logilab/pylint/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28160/PySrc/ThirdParty/logilab/pylint/test Modified Files: func_test_sample_config.py test_format.py test_indirectInterface.py unittest_lint.py test_encoding.py smoketest.py unittest_checkers_utils.py func_test.py Log Message: updated pylint Index: func_test.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/ThirdParty/logilab/pylint/test/func_test.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** func_test.py 24 Feb 2005 18:28:47 -0000 1.3 --- func_test.py 19 Apr 2005 14:39:10 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- import sys import re + import new from os import linesep from os.path import exists *************** *** 51,56 **** INFO_TEST_RGX = re.compile('^func_i\d\d\d\d$') class LintTest(testlib.TestCase): ! def test_functionality(self): tocheck = ['input.'+self.module] --- 52,61 ---- INFO_TEST_RGX = re.compile('^func_i\d\d\d\d$') + def exception_str(ex): + """function used to replace default __str__ method of exception instances""" + return 'in %s\n:: %s' % (ex.file, ', '.join(ex.args)) + class LintTest(testlib.TestCase): ! def test_functionality(self): tocheck = ['input.'+self.module] *************** *** 65,70 **** else: linter.disable_message_category('I') ! ! linter.check(tocheck) if self.module.startswith('func_noerror_'): expected = '' --- 70,81 ---- else: linter.disable_message_category('I') ! try: ! linter.check(tocheck) ! except Exception, ex: ! # need finalization to restore a correct state ! linter.reporter.finalize() ! ex.file = tocheck ! ex.__str__ = new.instancemethod(exception_str, ex) ! raise if self.module.startswith('func_noerror_'): expected = '' *************** *** 77,81 **** self.assertLinesEquals(got, expected) except Exception, ex: ! raise AssertionError('%s: %r\n!=\n%r\n\n%s' % (self.module, got, expected, ex)) class LintTest2(LintTest): --- 88,94 ---- self.assertLinesEquals(got, expected) except Exception, ex: ! ex.file = tocheck ! ex.__str__ = new.instancemethod(exception_str, ex) ! raise # AssertionError('%s: %r\n!=\n%r\n\n%s' % (self.module, got, expected, ex)) class LintTest2(LintTest): *************** *** 101,109 **** ! def make_tests(): """generate tests classes from test info return the list of generated test classes """ tests = [] for module_file, messages_file in get_tests_info('func_', '.py') + [('nonexistant', 'messages/nonexistant.txt')]: --- 114,126 ---- ! def make_tests(filter_rgx): """generate tests classes from test info return the list of generated test classes """ + if filter_rgx: + is_to_run = re.compile(filter_rgx).match + else: + is_to_run = lambda x: 1 tests = [] for module_file, messages_file in get_tests_info('func_', '.py') + [('nonexistant', 'messages/nonexistant.txt')]: *************** *** 112,115 **** --- 129,134 ---- ):#"func_nonascii_noencoding.py"): continue + if not is_to_run(module_file): + continue base = module_file.replace('func_', '').replace('.py', '') dependancies = get_tests_info(base, '.py') *************** *** 134,156 **** ## depends = dependancies or None ## tests.append(LintTestSubclass) ! ! class LintBuiltinModuleTest(LintTest): ! output = 'messages/builtin_module.txt' ! module = 'sys' ! def test_functionality(self): ! self._test(['sys']) ! ! tests.append(LintBuiltinModuleTest) ! ! # test all features are tested :) ! tests.append(TestTests) return tests def suite(): return unittest.TestSuite([unittest.makeSuite(test) ! for test in make_tests()]) if __name__=='__main__': unittest.main(defaultTest='suite') --- 153,181 ---- ## depends = dependancies or None ## tests.append(LintTestSubclass) ! ! if not filter_rgx: ! class LintBuiltinModuleTest(LintTest): ! output = 'messages/builtin_module.txt' ! module = 'sys' ! def test_functionality(self): ! self._test(['sys']) ! ! tests.append(LintBuiltinModuleTest) ! ! # test all features are tested :) ! tests.append(TestTests) return tests + FILTER_RGX = None + def suite(): return unittest.TestSuite([unittest.makeSuite(test) ! for test in make_tests(FILTER_RGX)]) if __name__=='__main__': + if len(sys.argv) > 1: + FILTER_RGX = sys.argv[1] + del sys.argv[1] unittest.main(defaultTest='suite') Index: unittest_lint.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/ThirdParty/logilab/pylint/test/unittest_lint.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** unittest_lint.py 24 Feb 2005 18:28:47 -0000 1.3 --- unittest_lint.py 19 Apr 2005 14:39:10 -0000 1.4 *************** *** 39,42 **** --- 39,43 ---- 'E0501', 'E0503', 'F0002', 'F0203']) + try: optimized = True *************** *** 56,72 **** class RunTC(unittest.TestCase): ! ! def test_no_args(self): sys.stdout = StringIO() try: try: ! Run([]) except SystemExit, ex: ! self.assertEquals(ex.code, 1) else: ! self.fail() finally: sys.stdout = sys.__stdout__ ! class PyLinterTC(unittest.TestCase): --- 57,83 ---- class RunTC(unittest.TestCase): ! ! def _test_run(self, args, exit_code=1, no_exit_fail=True): sys.stdout = StringIO() + sys.sterr = StringIO() try: try: ! Run(args) except SystemExit, ex: ! self.assertEquals(ex.code, exit_code) else: ! if no_exit_fail: ! self.fail() finally: sys.stdout = sys.__stdout__ ! sys.stderr = sys.__stderr__ ! ! def test_no_args(self): ! self._test_run([], 1) ! ! def test_no_ext_file(self): ! self._test_run([join('input', 'noext')], no_exit_fail=False) ! ! class PyLinterTC(unittest.TestCase): |