diff options
author | Éric Araujo <merwok@netwok.org> | 2012-02-25 16:24:59 +0100 |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2012-02-25 16:24:59 +0100 |
commit | e84e263a84745c9cbede0ac9385e2cff3f8ebfdf (patch) | |
tree | 11ef58b05f6c3e9d4e8b145899d314f965583d2b /Lib/test/test_tools.py | |
parent | 31378df83a5562df10b21f3f32d3b3a6cbfa054b (diff) | |
download | cpython-git-e84e263a84745c9cbede0ac9385e2cff3f8ebfdf.tar.gz |
Add test file for scripts in Tools (#13447).
When people find bugs in scripts such as reindent.py, msgfmt.py or
pygettext.py, we have to try to reproduce the bug manually, apply a fix
and test manually again. The alternative is to only read the code and
trust that it works. This test file is a way to stop that
unsatisfactory state of things and write proper unit tests instead.
Diffstat (limited to 'Lib/test/test_tools.py')
-rw-r--r-- | Lib/test/test_tools.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py new file mode 100644 index 0000000000..0cad0c4c91 --- /dev/null +++ b/Lib/test/test_tools.py @@ -0,0 +1,39 @@ +"""Tests for scripts in the Tools directory. + +This file contains regression tests for some of the scripts found in the +Tools directory of a Python checkout or tarball, such as reindent.py. +""" + +import os +import unittest +import sysconfig +from test import test_support +from test.script_helper import assert_python_ok + +if not sysconfig.is_python_build(): + # XXX some installers do contain the tools, should we detect that + # and run the tests in that case too? + raise unittest.SkipTest('test irrelevant for an installed Python') + +srcdir = sysconfig.get_config_var('projectbase') +basepath = os.path.join(os.getcwd(), srcdir, 'Tools') + + +class ReindentTests(unittest.TestCase): + script = os.path.join(basepath, 'scripts', 'reindent.py') + + def test_noargs(self): + assert_python_ok(self.script) + + def test_help(self): + rc, out, err = assert_python_ok(self.script, '-h') + self.assertEqual(out, b'') + self.assertGreater(err, b'') + + +def test_main(): + test_support.run_unittest(ReindentTests) + + +if __name__ == '__main__': + unittest.main() |