From b46562480b350984e7e81693936d1ed471a96b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 25 Feb 2012 16:57:04 +0100 Subject: 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. --- Lib/test/test_tools.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Lib/test/test_tools.py diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py new file mode 100644 index 0000000..1682124 --- /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 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(): + support.run_unittest(ReindentTests) + + +if __name__ == '__main__': + unittest.main() -- cgit v0.12 From e7295a76357aea6cc479f62b0aa1e93543e2aa53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sat, 25 Feb 2012 16:57:39 +0100 Subject: Add news entry for previous commit --- Misc/NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 329770f..0375ff3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,9 @@ Core and Builtins Library ------- +- Issue #13447: Add a test file to host regression tests for bugs in the + scripts found in the Tools directory. + - Issue #6884: Fix long-standing bugs with MANIFEST.in parsing in distutils on Windows. -- cgit v0.12