From b07b97f3a40d8970e5d766304c04a525c043c753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:03:34 +0200 Subject: Minor updates to the whatsnew maintenance rules --- Doc/whatsnew/3.3.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst index c2cf524..f208660 100644 --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -6,8 +6,7 @@ :Release: |release| :Date: |today| -.. $Id$ - Rules for maintenance: +.. Rules for maintenance: * Anyone can add text to this document. Do not spend very much time on the wording of your changes, because your text will probably @@ -40,12 +39,11 @@ * It's helpful to add the bug/patch number as a comment: - % Patch 12345 XXX Describe the transmogrify() function added to the socket module. - (Contributed by P.Y. Developer.) + (Contributed by P.Y. Developer in :issue:`12345`.) - This saves the maintainer the effort of going through the SVN log + This saves the maintainer the effort of going through the Mercurial log when researching a change. This article explains the new features in Python 3.3, compared to 3.2. @@ -109,6 +107,7 @@ XXX Add list of changes introduced by :pep:`393` here: XXX mention new and deprecated functions and macros + Other Language Changes ====================== -- cgit v0.12 From 5043f0904ba2254cbd65b41e3870c62a682e1c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:04:18 +0200 Subject: More info about PEP 393 in whatsnew and NEWS --- Doc/whatsnew/3.3.rst | 11 ++++++----- Misc/NEWS | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst index f208660..a3abc11 100644 --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -49,14 +49,15 @@ This article explains the new features in Python 3.3, compared to 3.2. -PEP XXX: Stub -============= - - PEP 393: Flexible String Representation ======================================= -XXX Give a short introduction about :pep:`393`. +[Abstract copied from the PEP: The Unicode string type is changed to support +multiple internal representations, depending on the character with the largest +Unicode ordinal (1, 2, or 4 bytes). This allows a space-efficient +representation in common cases, but gives access to full UCS-4 on all systems. +For compatibility with existing APIs, several representations may exist in +parallel; over time, this compatibility should be phased out.] PEP 393 is fully backward compatible. The legacy API should remain available at least five years. Applications using the legacy API will not diff --git a/Misc/NEWS b/Misc/NEWS index 025d42a..0b9cfbd 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1261,6 +1261,8 @@ Library Build ----- +- PEP 393: the configure option --with-wide-unicode is removed. + - Issue #12852: Set _XOPEN_SOURCE to 700, instead of 600, to get POSIX 2008 functions on OpenBSD (e.g. fdopendir). -- cgit v0.12 From 525b1e9dd4de54575a57458b2ac0a59d45cf0885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:06:31 +0200 Subject: Fix minor wording issue. sys.maxunicode is not called and thus does not return anything; it *is* something. (I checked the doc quickly to see if it tells that expression return things but found nothing.) I also removed markup that would just generate a useless link to the enclosing section. --- Doc/library/sys.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 43f65e2..a64c221 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -629,7 +629,7 @@ always available. i.e. ``1114111`` (``0x10FFFF`` in hexadecimal). .. versionchanged:: 3.3 - Before :pep:`393`, :data:`sys.maxunicode` used to return either ``0xFFFF`` + Before :pep:`393`, ``sys.maxunicode`` used to be either ``0xFFFF`` or ``0x10FFFF``, depending on the configuration option that specified whether Unicode characters were stored as UCS-2 or UCS-4. -- cgit v0.12 From 80a348c0a0a97c2d55a65dc45bbfbe7c7a74953e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:11:12 +0200 Subject: Fix typo --- Include/unicodeobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index a18b3dd..1b4522d 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -206,7 +206,7 @@ extern "C" { immediately follow the structure. utf8_length and wstr_length can be found in the length field; the utf8 pointer is equal to the data pointer. */ typedef struct { - /* There a 4 forms of Unicode strings: + /* There are 4 forms of Unicode strings: - compact ascii: -- cgit v0.12 From 56fab3daed27f53e1f7c59a1b2481d7be9175a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:14:02 +0200 Subject: Remove inline comment, no longer supported by configparser. (Deleted rather than moved because multilib implementations vary.) --- Lib/sysconfig.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/sysconfig.cfg b/Lib/sysconfig.cfg index 573b12e..565c0eb 100644 --- a/Lib/sysconfig.cfg +++ b/Lib/sysconfig.cfg @@ -31,7 +31,7 @@ man = {datadir}/man # be used directly in [resource_locations]. confdir = /etc datadir = /usr/share -libdir = /usr/lib ; or /usr/lib64 on a multilib system +libdir = /usr/lib statedir = /var # User resource directory local = ~/.local/{distribution.name} -- cgit v0.12 From da27263b4a7aa6af7d2bf6967a15b0007aa1ae2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:17:38 +0200 Subject: Move doc of sys.dont_write_bytecode to make all attributes sorted again --- Doc/library/sys.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 7f3d827..105f716 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -121,6 +121,15 @@ always available. Use ``'backslashreplace'`` error handler on :exc:`UnicodeEncodeError`. +.. data:: dont_write_bytecode + + If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the + import of source modules. This value is initially set to ``True`` or + ``False`` depending on the :option:`-B` command line option and the + :envvar:`PYTHONDONTWRITEBYTECODE` environment variable, but you can set it + yourself to control bytecode file generation. + + .. function:: excepthook(type, value, traceback) This function prints out a given traceback and exception to ``sys.stderr``. @@ -764,15 +773,6 @@ always available. implement a dynamic prompt. -.. data:: dont_write_bytecode - - If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the - import of source modules. This value is initially set to ``True`` or ``False`` - depending on the ``-B`` command line option and the ``PYTHONDONTWRITEBYTECODE`` - environment variable, but you can set it yourself to control bytecode file - generation. - - .. function:: setcheckinterval(interval) Set the interpreter's "check interval". This integer value determines how often -- cgit v0.12 From 58a9153c9f49fcfe58a9e91b08167ff3483b36f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:28:24 +0200 Subject: Fix markup used in the documentation of sys.prefix and sys.exec_prefix. - Using the file role with {placeholders} is IMO clearer than fake Python code. - The fact that sys.version[:3] gives '3.2' is a CPython detail and should not be advertised (see #9442), even if some stdlib modules currently rely on that detail. --- Doc/library/sys.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 105f716..fdf188f 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -194,10 +194,10 @@ always available. Python files are installed; by default, this is also ``'/usr/local'``. This can be set at build time with the ``--exec-prefix`` argument to the :program:`configure` script. Specifically, all configuration files (e.g. the - :file:`pyconfig.h` header file) are installed in the directory ``exec_prefix + - '/lib/pythonversion/config'``, and shared library modules are installed in - ``exec_prefix + '/lib/pythonversion/lib-dynload'``, where *version* is equal to - ``version[:3]``. + :file:`pyconfig.h` header file) are installed in the directory + :file:`{exec_prefix}/lib/python{X.Y}/config', and shared library modules are + installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* + is the version number of Python, for example ``3.2``. .. data:: executable @@ -752,10 +752,10 @@ always available. independent Python files are installed; by default, this is the string ``'/usr/local'``. This can be set at build time with the ``--prefix`` argument to the :program:`configure` script. The main collection of Python - library modules is installed in the directory ``prefix + '/lib/pythonversion'`` + library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}`` while the platform independent header files (all except :file:`pyconfig.h`) are - stored in ``prefix + '/include/pythonversion'``, where *version* is equal to - ``version[:3]``. + stored in :file:`{prefix}/include/python{X.Y}``, where *X.Y* is the version + number of Python, for example ``3.2``. .. data:: ps1 -- cgit v0.12 From 63ba97b58608163e1fabf0e07c4f7a243a028e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:29:22 +0200 Subject: Fix typo and case in a recently added test --- Lib/test/test_minidom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 5c09c46..126bdb1 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -446,7 +446,7 @@ class MinidomTest(unittest.TestCase): dom.unlink() self.confirm(domstr == str.replace("\n", "\r\n")) - def test_toPrettyXML_perserves_content_of_text_node(self): + def test_toprettyxml_preserves_content_of_text_node(self): str = 'B' dom = parseString(str) dom2 = parseString(dom.toprettyxml()) -- cgit v0.12 From 763cc6eaee612d803815a5eea28b95c39f6dce48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:41:14 +0200 Subject: Add tests for comparing candidate and final versions in packaging (#11841). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This used to be buggy; Filip Gruszczyński contributed tests and a code patch but the latter is not needed. --- Lib/packaging/tests/test_version.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/packaging/tests/test_version.py b/Lib/packaging/tests/test_version.py index f94c800..54a9e7a 100644 --- a/Lib/packaging/tests/test_version.py +++ b/Lib/packaging/tests/test_version.py @@ -101,8 +101,18 @@ class VersionTestCase(unittest.TestCase): True >>> V('1.2.0') >= V('1.2.3') False + >>> V('1.2.0rc1') >= V('1.2.0') + False >>> (V('1.0') > V('1.0b2')) True + >>> V('1.0') > V('1.0c2') + True + >>> V('1.0') > V('1.0rc2') + True + >>> V('1.0rc2') > V('1.0rc1') + True + >>> V('1.0c4') > V('1.0c1') + True >>> (V('1.0') > V('1.0c2') > V('1.0c1') > V('1.0b2') > V('1.0b1') ... > V('1.0a2') > V('1.0a1')) True @@ -129,6 +139,8 @@ class VersionTestCase(unittest.TestCase): ... < V('1.0.dev18') ... < V('1.0.dev456') ... < V('1.0.dev1234') + ... < V('1.0rc1') + ... < V('1.0rc2') ... < V('1.0') ... < V('1.0.post456.dev623') # development version of a post release ... < V('1.0.post456')) -- cgit v0.12 From c4637714b0d1c80a8a7d40a590b1a113bf112ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:46:37 +0200 Subject: Cosmetic fixes for whitespace and a regex in packaging. The goal of the regex is to catch a (alpha), b (beta), c or rc (release candidate), so the existing pattern puzzled me. Tests were OK before and after the change. --- Lib/packaging/tests/test_version.py | 8 ++++---- Lib/packaging/version.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/packaging/tests/test_version.py b/Lib/packaging/tests/test_version.py index 54a9e7a..2c86111 100644 --- a/Lib/packaging/tests/test_version.py +++ b/Lib/packaging/tests/test_version.py @@ -103,7 +103,7 @@ class VersionTestCase(unittest.TestCase): False >>> V('1.2.0rc1') >= V('1.2.0') False - >>> (V('1.0') > V('1.0b2')) + >>> V('1.0') > V('1.0b2') True >>> V('1.0') > V('1.0c2') True @@ -248,9 +248,9 @@ class VersionWhiteBoxTestCase(unittest.TestCase): def test_parse_numdots(self): # For code coverage completeness, as pad_zeros_length can't be set or # influenced from the public interface - self.assertEqual(V('1.0')._parse_numdots('1.0', '1.0', - pad_zeros_length=3), - [1, 0, 0]) + self.assertEqual( + V('1.0')._parse_numdots('1.0', '1.0', pad_zeros_length=3), + [1, 0, 0]) def test_suite(): diff --git a/Lib/packaging/version.py b/Lib/packaging/version.py index 0eaf80b..7d812bb 100644 --- a/Lib/packaging/version.py +++ b/Lib/packaging/version.py @@ -253,7 +253,7 @@ def suggest_normalized_version(s): # if we have something like "b-2" or "a.2" at the end of the # version, that is pobably beta, alpha, etc # let's remove the dash or dot - rs = re.sub(r"([abc|rc])[\-\.](\d+)$", r"\1\2", rs) + rs = re.sub(r"([abc]|rc)[\-\.](\d+)$", r"\1\2", rs) # 1.0-dev-r371 -> 1.0.dev371 # 0.1-dev-r79 -> 0.1.dev79 -- cgit v0.12 From 4300f69afd6278b890ae4d69cfa7b36daac02fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Wed, 5 Oct 2011 01:50:22 +0200 Subject: Update skip message printed by test.support.get_attribute. This helper was changed to work with any object instead of only modules (or technically something with a __name__ attribute, see code in 3.2) but the message stayed as is. --- Lib/test/support.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/support.py b/Lib/test/support.py index 619bf4c..556e82f4 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -187,8 +187,7 @@ def get_attribute(obj, name): try: attribute = getattr(obj, name) except AttributeError: - raise unittest.SkipTest("module %s has no attribute %s" % ( - repr(obj), name)) + raise unittest.SkipTest("object %r has no attribute %r" % (obj, name)) else: return attribute -- cgit v0.12 From 76558e12ad377a0bc160935cf17ef54ff3292a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 02:44:19 +0200 Subject: Add regrtest check for caches in packaging.database (see #12167) --- Lib/test/regrtest.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index e46f935..59bdb01 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -173,6 +173,7 @@ import io import json import logging import os +import packaging.database import platform import random import re @@ -967,6 +968,7 @@ class saved_test_environment: 'sys.warnoptions', 'threading._dangling', 'multiprocessing.process._dangling', 'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES', + 'packaging.database_caches', ) def get_sys_argv(self): @@ -1054,6 +1056,28 @@ class saved_test_environment: # Can't easily revert the logging state pass + def get_packaging_database_caches(self): + # caching system used by the PEP 376 implementation + # we have one boolean and four dictionaries, initially empty + switch = packaging.database._cache_enabled + saved = [] + for name in ('_cache_name', '_cache_name_egg', + '_cache_path', '_cache_path_egg'): + cache = getattr(packaging.database, name) + saved.append((id(cache), cache, cache.copy())) + return switch, saved + def restore_packaging_database_caches(self, saved): + switch, saved_caches = saved + packaging.database._cache_enabled = switch + for offset, name in enumerate(('_cache_name', '_cache_name_egg', + '_cache_path', '_cache_path_egg')): + _, cache, items = saved_caches[offset] + # put back the same object in place + setattr(packaging.database, name, cache) + # now restore its items + cache.clear() + cache.update(items) + def get_sys_warnoptions(self): return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:] def restore_sys_warnoptions(self, saved_options): -- cgit v0.12 From 2c30e3999cb2a1c46d19d903b055cf4267a27f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 04:59:41 +0200 Subject: =?UTF-8?q?Change=20one=20name=20in=20packaging=E2=80=99s=20test?= =?UTF-8?q?=5Funinstall=20to=20avoid=20confusion.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit install_lib may be the name of a module, a command or an option, so I find it clearer to use site_packages to refer to a string object containing the path of the site-packages directory created in a temporary directory during tests. --- Lib/packaging/tests/test_uninstall.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index c7702de..e42b48e 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -86,26 +86,26 @@ class UninstallTestCase(support.TempdirManager, old_out = sys.stderr sys.stderr = StringIO() dist = self.run_setup('install_dist', '--prefix=' + self.root_dir) - install_lib = self.get_path(dist, 'purelib') - return dist, install_lib + site_packages = self.get_path(dist, 'purelib') + return dist, site_packages def test_uninstall_unknow_distribution(self): self.assertRaises(PackagingError, remove, 'Foo', paths=[self.root_dir]) def test_uninstall(self): - dist, install_lib = self.install_dist() - self.assertIsFile(install_lib, 'foo', '__init__.py') - self.assertIsFile(install_lib, 'foo', 'sub', '__init__.py') - self.assertIsFile(install_lib, 'Foo-0.1.dist-info', 'RECORD') - self.assertTrue(remove('Foo', paths=[install_lib])) - self.assertIsNotFile(install_lib, 'foo', 'sub', '__init__.py') - self.assertIsNotFile(install_lib, 'Foo-0.1.dist-info', 'RECORD') + dist, site_packages = self.install_dist() + self.assertIsFile(site_packages, 'foo', '__init__.py') + self.assertIsFile(site_packages, 'foo', 'sub', '__init__.py') + self.assertIsFile(site_packages, 'Foo-0.1.dist-info', 'RECORD') + self.assertTrue(remove('Foo', paths=[site_packages])) + self.assertIsNotFile(site_packages, 'foo', 'sub', '__init__.py') + self.assertIsNotFile(site_packages, 'Foo-0.1.dist-info', 'RECORD') def test_remove_issue(self): # makes sure if there are OSErrors (like permission denied) # remove() stops and display a clean error - dist, install_lib = self.install_dist('Meh') + dist, site_packages = self.install_dist('Meh') # breaking os.rename old = os.rename @@ -115,11 +115,11 @@ class UninstallTestCase(support.TempdirManager, os.rename = _rename try: - self.assertFalse(remove('Meh', paths=[install_lib])) + self.assertFalse(remove('Meh', paths=[site_packages])) finally: os.rename = old - self.assertTrue(remove('Meh', paths=[install_lib])) + self.assertTrue(remove('Meh', paths=[site_packages])) def test_suite(): -- cgit v0.12 From 9556a5bab277eff83b40236c58c3fb7d0233dc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 05:10:09 +0200 Subject: Fix incorrect test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The packaging.install.remove function (a.k.a. the uninstall feature) takes a path argument to allow client code to use custom directories instead of sys.path. The test used to give self.root_dir as path, which corresponds to a prefix option, but prefix is not on sys.path, it’s only the base directory used to compute the stdlib and site-packages directory paths. The test now gives a valid site-packages path to the function. --- Lib/packaging/tests/test_uninstall.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index e42b48e..614b187 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -89,9 +89,10 @@ class UninstallTestCase(support.TempdirManager, site_packages = self.get_path(dist, 'purelib') return dist, site_packages - def test_uninstall_unknow_distribution(self): + def test_uninstall_unknown_distribution(self): + dist, site_packages = self.install_dist('Foospam') self.assertRaises(PackagingError, remove, 'Foo', - paths=[self.root_dir]) + paths=[site_packages]) def test_uninstall(self): dist, site_packages = self.install_dist() -- cgit v0.12 From fa23cc842c22b945f1fd1126810991daddbd7314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 05:15:09 +0200 Subject: Add test that was promised in a comment but not actually written --- Lib/packaging/tests/test_uninstall.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index 614b187..7603a40 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -1,6 +1,7 @@ """Tests for the uninstall command.""" import os import sys +import logging from io import StringIO import stat import packaging.util @@ -105,14 +106,14 @@ class UninstallTestCase(support.TempdirManager, def test_remove_issue(self): # makes sure if there are OSErrors (like permission denied) - # remove() stops and display a clean error + # remove() stops and displays a clean error dist, site_packages = self.install_dist('Meh') # breaking os.rename old = os.rename def _rename(source, target): - raise OSError + raise OSError(42, 'impossible operation') os.rename = _rename try: @@ -120,6 +121,10 @@ class UninstallTestCase(support.TempdirManager, finally: os.rename = old + logs = [log for log in self.get_logs(logging.INFO) + if log.startswith('Error:')] + self.assertEqual(logs, ['Error: [Errno 42] impossible operation']) + self.assertTrue(remove('Meh', paths=[site_packages])) -- cgit v0.12 From 8ed34a130ea8c30b98bf45eaed8ffa68e7e6ed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 05:18:41 +0200 Subject: Minor: improve one test name, address pyflakes warnings --- Lib/packaging/tests/test_uninstall.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index 7603a40..49fcb42 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -1,15 +1,14 @@ -"""Tests for the uninstall command.""" +"""Tests for the packaging.uninstall module.""" import os import sys import logging -from io import StringIO -import stat import packaging.util -from packaging.database import disable_cache, enable_cache +from io import StringIO from packaging.run import main from packaging.errors import PackagingError from packaging.install import remove +from packaging.database import disable_cache, enable_cache from packaging.command.install_dist import install_dist from packaging.tests import unittest, support @@ -84,7 +83,6 @@ class UninstallTestCase(support.TempdirManager, if not dirname: dirname = self.make_dist(name, **kw) os.chdir(dirname) - old_out = sys.stderr sys.stderr = StringIO() dist = self.run_setup('install_dist', '--prefix=' + self.root_dir) site_packages = self.get_path(dist, 'purelib') @@ -104,7 +102,7 @@ class UninstallTestCase(support.TempdirManager, self.assertIsNotFile(site_packages, 'foo', 'sub', '__init__.py') self.assertIsNotFile(site_packages, 'Foo-0.1.dist-info', 'RECORD') - def test_remove_issue(self): + def test_uninstall_error_handling(self): # makes sure if there are OSErrors (like permission denied) # remove() stops and displays a clean error dist, site_packages = self.install_dist('Meh') -- cgit v0.12 From 6fd287e6c2024206c07d336b86edb10c3a17c4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Thu, 6 Oct 2011 05:28:56 +0200 Subject: =?UTF-8?q?Fix=20return=20code=20of=20=E2=80=9Cpysetup=20run=20COM?= =?UTF-8?q?MAND=E2=80=9D=20(closes=20#12222)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/packaging/run.py | 5 +++-- Lib/packaging/tests/test_uninstall.py | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py index 5affb17..59ad6ee 100644 --- a/Lib/packaging/run.py +++ b/Lib/packaging/run.py @@ -283,10 +283,11 @@ def _run(dispatcher, args, **kw): dist.parse_config_files() for cmd in dispatcher.commands: + # FIXME need to catch MetadataMissingError here (from the check command + # e.g.)--or catch any exception, print an error message and exit with 1 dist.run_command(cmd, dispatcher.command_options[cmd]) - # XXX this is crappy - return dist + return 0 @action_help("""\ diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index 49fcb42..8f094f4 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -4,12 +4,9 @@ import sys import logging import packaging.util -from io import StringIO -from packaging.run import main from packaging.errors import PackagingError from packaging.install import remove from packaging.database import disable_cache, enable_cache -from packaging.command.install_dist import install_dist from packaging.tests import unittest, support @@ -47,16 +44,12 @@ class UninstallTestCase(support.TempdirManager, packaging.util._path_created.clear() super(UninstallTestCase, self).tearDown() - def run_setup(self, *args): - # run setup with args - args = ['run'] + list(args) - dist = main(args) - return dist - def get_path(self, dist, name): - cmd = install_dist(dist) - cmd.prefix = self.root_dir - cmd.finalize_options() + # the dist argument must contain an install_dist command correctly + # initialized with a prefix option and finalized befored this method + # can be called successfully; practically, this means that you should + # call self.install_dist before self.get_path + cmd = dist.get_command_obj('install_dist') return getattr(cmd, 'install_' + name) def make_dist(self, name='Foo', **kw): @@ -83,8 +76,17 @@ class UninstallTestCase(support.TempdirManager, if not dirname: dirname = self.make_dist(name, **kw) os.chdir(dirname) - sys.stderr = StringIO() - dist = self.run_setup('install_dist', '--prefix=' + self.root_dir) + + dist = support.TestDistribution() + # for some unfathomable reason, the tests will fail horribly if the + # parse_config_files method is not called, even if it doesn't do + # anything useful; trying to build and use a command object manually + # also fails + dist.parse_config_files() + dist.finalize_options() + dist.run_command('install_dist', + {'prefix': ('command line', self.root_dir)}) + site_packages = self.get_path(dist, 'purelib') return dist, site_packages -- cgit v0.12