Éric Araujo | e84e263 | 2012-02-25 16:24:59 +0100 | [diff] [blame^] | 1 | """Tests for scripts in the Tools directory. |
| 2 | |
| 3 | This file contains regression tests for some of the scripts found in the |
| 4 | Tools directory of a Python checkout or tarball, such as reindent.py. |
| 5 | """ |
| 6 | |
| 7 | import os |
| 8 | import unittest |
| 9 | import sysconfig |
| 10 | from test import test_support |
| 11 | from test.script_helper import assert_python_ok |
| 12 | |
| 13 | if not sysconfig.is_python_build(): |
| 14 | # XXX some installers do contain the tools, should we detect that |
| 15 | # and run the tests in that case too? |
| 16 | raise unittest.SkipTest('test irrelevant for an installed Python') |
| 17 | |
| 18 | srcdir = sysconfig.get_config_var('projectbase') |
| 19 | basepath = os.path.join(os.getcwd(), srcdir, 'Tools') |
| 20 | |
| 21 | |
| 22 | class ReindentTests(unittest.TestCase): |
| 23 | script = os.path.join(basepath, 'scripts', 'reindent.py') |
| 24 | |
| 25 | def test_noargs(self): |
| 26 | assert_python_ok(self.script) |
| 27 | |
| 28 | def test_help(self): |
| 29 | rc, out, err = assert_python_ok(self.script, '-h') |
| 30 | self.assertEqual(out, b'') |
| 31 | self.assertGreater(err, b'') |
| 32 | |
| 33 | |
| 34 | def test_main(): |
| 35 | test_support.run_unittest(ReindentTests) |
| 36 | |
| 37 | |
| 38 | if __name__ == '__main__': |
| 39 | unittest.main() |