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 From a6091998afc5bb7940315ef7b105e1703f64a375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 02:13:30 +0100 Subject: Use const markup instead of a misleading string literal --- Doc/library/logging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst index c429c85..26fa97e 100644 --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -1077,7 +1077,7 @@ with the :mod:`warnings` module. If *capture* is ``True``, warnings issued by the :mod:`warnings` module will be redirected to the logging system. Specifically, a warning will be formatted using :func:`warnings.formatwarning` and the resulting string - logged to a logger named ``'py.warnings'`` with a severity of ``'WARNING'``. + logged to a logger named ``'py.warnings'`` with a severity of :const:`WARNING`. If *capture* is ``False``, the redirection of warnings to the logging system will stop, and warnings will be redirected to their original destinations -- cgit v0.12 From fab976624df27bfcf999f93a1047173c27555725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 02:14:08 +0100 Subject: =?UTF-8?q?Fix=20typo=20in=20=E2=80=9Cseperat{or,ion}=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/_io/_iomodule.c | 2 +- Modules/_io/textio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 61362c7..4c90433 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -58,7 +58,7 @@ PyDoc_STRVAR(module_doc, "\n" "At the top of the I/O hierarchy is the abstract base class IOBase. It\n" "defines the basic interface to a stream. Note, however, that there is no\n" -"seperation between reading and writing to streams; implementations are\n" +"separation between reading and writing to streams; implementations are\n" "allowed to throw an IOError if they do not support a given operation.\n" "\n" "Extending IOBase is RawIOBase which deals simply with the reading and\n" diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 9c5f441..baf0a97 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -627,7 +627,7 @@ PyDoc_STRVAR(textiowrapper_doc, "enabled. With this enabled, on input, the lines endings '\\n', '\\r',\n" "or '\\r\\n' are translated to '\\n' before being returned to the\n" "caller. Conversely, on output, '\\n' is translated to the system\n" - "default line seperator, os.linesep. If newline is any other of its\n" + "default line separator, os.linesep. If newline is any other of its\n" "legal values, that newline becomes the newline when the file is read\n" "and it is returned untranslated. On output, '\\n' is converted to the\n" "newline.\n" -- cgit v0.12 From 845a77205f9282c2f1aa36d3c4cc554b66689151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Sun, 26 Feb 2012 02:14:33 +0100 Subject: Set archive format explicitly in one distutils test --- Lib/distutils/tests/test_sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py index fd71dac..1ba2a1a 100644 --- a/Lib/distutils/tests/test_sdist.py +++ b/Lib/distutils/tests/test_sdist.py @@ -6,6 +6,7 @@ import warnings import zipfile from os.path import join from textwrap import dedent +from test.support import captured_stdout, check_warnings, run_unittest try: import zlib @@ -13,7 +14,6 @@ try: except ImportError: ZLIB_SUPPORT = False -from test.support import captured_stdout, check_warnings, run_unittest from distutils.command.sdist import sdist, show_formats from distutils.core import Distribution @@ -326,6 +326,7 @@ class SDistTestCase(PyPIRCCommandTestCase): # filling data_files by pointing files in package_data dist.package_data = {'somecode': ['*.txt']} self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#') + cmd.formats = ['gztar'] cmd.ensure_finalized() cmd.run() -- cgit v0.12