pep8: Move to third_party/.
[Samba.git] / third_party / pep8 / testsuite / test_all.py
blob50e2cb9fbde2737dac0e6daa8479474fd6a537f7
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 import os.path
4 import sys
5 import unittest
7 import pep8
8 from testsuite.support import init_tests, selftest, ROOT_DIR
10 # Note: please only use a subset of unittest methods which were present
11 # in Python 2.5: assert(True|False|Equal|NotEqual|Raises)
14 class Pep8TestCase(unittest.TestCase):
15 """Test the standard errors and warnings (E and W)."""
17 def setUp(self):
18 self._style = pep8.StyleGuide(
19 paths=[os.path.join(ROOT_DIR, 'testsuite')],
20 select='E,W', quiet=True)
22 def test_doctest(self):
23 import doctest
24 fail_d, done_d = doctest.testmod(pep8, verbose=False, report=False)
25 self.assertTrue(done_d, msg='tests not found')
26 self.assertFalse(fail_d, msg='%s failure(s)' % fail_d)
28 def test_selftest(self):
29 fail_s, done_s = selftest(self._style.options)
30 self.assertTrue(done_s, msg='tests not found')
31 self.assertFalse(fail_s, msg='%s failure(s)' % fail_s)
33 def test_checkers_testsuite(self):
34 init_tests(self._style)
35 report = self._style.check_files()
36 self.assertFalse(report.total_errors,
37 msg='%s failure(s)' % report.total_errors)
39 def test_own_dog_food(self):
40 files = [pep8.__file__.rstrip('oc'), __file__.rstrip('oc'),
41 os.path.join(ROOT_DIR, 'setup.py')]
42 report = self._style.init_report(pep8.StandardReport)
43 report = self._style.check_files(files)
44 self.assertFalse(report.total_errors,
45 msg='Failures: %s' % report.messages)
48 def suite():
49 from testsuite import test_api, test_shell, test_util
51 suite = unittest.TestSuite()
52 suite.addTest(unittest.makeSuite(Pep8TestCase))
53 suite.addTest(unittest.makeSuite(test_api.APITestCase))
54 suite.addTest(unittest.makeSuite(test_shell.ShellTestCase))
55 suite.addTest(unittest.makeSuite(test_util.UtilTestCase))
56 return suite
59 def _main():
60 return unittest.TextTestRunner(verbosity=2).run(suite())
62 if __name__ == '__main__':
63 sys.exit(not _main())