mirror of https://github.com/python/cpython
Merged revisions 70912,70944,70968,71033,71041,71208,71263,71286,71395-71396,71405-71406,71485,71492,71494 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70912 | georg.brandl | 2009-03-31 17:35:46 -0500 (Tue, 31 Mar 2009) | 1 line #5617: add a handy function to print a unicode string to gdbinit. ........ r70944 | georg.brandl | 2009-03-31 23:32:39 -0500 (Tue, 31 Mar 2009) | 1 line #5631: add upload to list of possible commands, which is presented in --help-commands. ........ r70968 | michael.foord | 2009-04-01 13:25:38 -0500 (Wed, 01 Apr 2009) | 1 line Adding Wing project file ........ r71033 | brett.cannon | 2009-04-01 22:34:53 -0500 (Wed, 01 Apr 2009) | 3 lines Fix two issues introduced by issue #71031 by changing the signature of PyImport_AppendInittab() to take a const char *. ........ r71041 | jesse.noller | 2009-04-02 00:17:26 -0500 (Thu, 02 Apr 2009) | 1 line Add custom initializer argument to multiprocess.Manager*, courtesy of lekma ........ r71208 | michael.foord | 2009-04-04 20:15:01 -0500 (Sat, 04 Apr 2009) | 4 lines Change the way unittest.TestSuite use their tests to always access them through iteration. Non behavior changing, this allows you to create custom subclasses that override __iter__. Issue #5693 ........ r71263 | michael.foord | 2009-04-05 14:19:28 -0500 (Sun, 05 Apr 2009) | 4 lines Adding assertIs and assertIsNot methods to unittest.TestCase Issue #2578 ........ r71286 | tarek.ziade | 2009-04-05 17:04:38 -0500 (Sun, 05 Apr 2009) | 1 line added a simplest test to distutils.spawn._nt_quote_args ........ r71395 | benjamin.peterson | 2009-04-08 08:27:29 -0500 (Wed, 08 Apr 2009) | 1 line these must be installed to correctly run tests ........ r71396 | benjamin.peterson | 2009-04-08 08:29:41 -0500 (Wed, 08 Apr 2009) | 1 line fix syntax ........ r71405 | andrew.kuchling | 2009-04-09 06:22:47 -0500 (Thu, 09 Apr 2009) | 1 line Add items ........ r71406 | andrew.kuchling | 2009-04-09 06:23:36 -0500 (Thu, 09 Apr 2009) | 1 line Typo fixes ........ r71485 | andrew.kuchling | 2009-04-11 11:12:23 -0500 (Sat, 11 Apr 2009) | 1 line Add various items ........ r71492 | georg.brandl | 2009-04-11 13:19:27 -0500 (Sat, 11 Apr 2009) | 1 line Take credit for a patch of mine. ........ r71494 | benjamin.peterson | 2009-04-11 14:31:00 -0500 (Sat, 11 Apr 2009) | 1 line ignore py3_test_grammar when compiling the library ........
This commit is contained in:
parent
a0a7faab91
commit
f47ed4a014
|
@ -1128,9 +1128,10 @@ their parent process exits. The manager classes are defined in the
|
|||
``current_process().authkey``. Otherwise *authkey* is used and it
|
||||
must be a string.
|
||||
|
||||
.. method:: start()
|
||||
.. method:: start([initializer[, initargs]])
|
||||
|
||||
Start a subprocess to start the manager.
|
||||
Start a subprocess to start the manager. If *initializer* is not ``None``
|
||||
then the subprocess will call ``initializer(*initargs)`` when it starts.
|
||||
|
||||
.. method:: serve_forever()
|
||||
|
||||
|
|
|
@ -689,7 +689,7 @@ Test cases
|
|||
assertLessEqual(first, second, msg=None)
|
||||
|
||||
Test that *first* is respectively >, >=, < or <= than *second* depending
|
||||
on the method name. If not, the test will fail with the nice explanation
|
||||
on the method name. If not, the test will fail with an explanation
|
||||
or with the explanation given by *msg*::
|
||||
|
||||
>>> self.assertGreaterEqual(3, 4)
|
||||
|
@ -722,7 +722,7 @@ Test cases
|
|||
.. method:: assertIn(first, second, msg=None)
|
||||
assertNotIn(first, second, msg=None)
|
||||
|
||||
Tests that *first* is or is not in *second* with a nice explanitory error
|
||||
Tests that *first* is or is not in *second* with an explanatory error
|
||||
message as appropriate.
|
||||
|
||||
If specified *msg* will be used as the error message on failure.
|
||||
|
@ -766,7 +766,7 @@ Test cases
|
|||
|
||||
.. method:: assertDictContainsSubset(expected, actual, msg=None)
|
||||
|
||||
Tests whether the key value pairs in dictionary *actual* are a
|
||||
Tests whether the key/value pairs in dictionary *actual* are a
|
||||
superset of those in *expected*. If not, an error message listing
|
||||
the missing keys and mismatched values is generated.
|
||||
|
||||
|
@ -858,6 +858,23 @@ Test cases
|
|||
.. versionadded:: 3.1
|
||||
|
||||
|
||||
.. method:: assertIs(expr1, expr2[, msg])
|
||||
|
||||
This signals a test failure if *expr1* and *expr2* don't evaluate to the same
|
||||
object.
|
||||
|
||||
.. versionadded:: 2.7
|
||||
|
||||
|
||||
.. method:: assertIsNot(expr1, expr2[, msg])
|
||||
|
||||
The inverse of the :meth:`assertIs` method.
|
||||
This signals a test failure if *expr1* and *expr2* evaluate to the same
|
||||
object.
|
||||
|
||||
.. versionadded:: 2.7
|
||||
|
||||
|
||||
.. method:: assertFalse(expr[, msg])
|
||||
failIf(expr[, msg])
|
||||
|
||||
|
@ -951,12 +968,12 @@ Test cases
|
|||
been asked to compare are exactly *typeobj* (not subclasses).
|
||||
*function* must take two positional arguments and a third msg=None
|
||||
keyword argument just as :meth:`assertEqual` does. It must raise
|
||||
self.failureException when inequality between the first two
|
||||
``self.failureException`` when inequality between the first two
|
||||
parameters is detected.
|
||||
|
||||
One good use of custom equality checking functions for a type
|
||||
is to raise self.failureException with an error message useful
|
||||
for debugging the by explaining the inequalities in detail.
|
||||
is to raise ``self.failureException`` with an error message useful
|
||||
for debugging the problem by explaining the inequalities in detail.
|
||||
|
||||
.. versionadded:: 3.1
|
||||
|
||||
|
|
|
@ -88,6 +88,23 @@ Other Language Changes
|
|||
|
||||
Some smaller changes made to the core Python language are:
|
||||
|
||||
* The string :method:`format` method now supports automatic numbering
|
||||
of the replacement fields. This makes using :meth:`format`
|
||||
more closely resemble using ``%s`` formatting::
|
||||
|
||||
>>> '{}:{}:{}'.format(2009, 04, 'Sunday')
|
||||
'2009:4:Sunday'
|
||||
>>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
|
||||
'2009:4:Sunday'
|
||||
|
||||
The auto-numbering takes the fields from left to right, so the first
|
||||
``{...}`` specifier will use the first argument to :meth:`format`,
|
||||
the next specifier will use the next argument, and so on. You can't
|
||||
mix auto-numbering and explicit numbering -- either number all of
|
||||
your specifier fields or none of them -- but you can mix
|
||||
auto-numbering and named fields, as in the second example above.
|
||||
(Contributed by XXX; :issue`5237`.)
|
||||
|
||||
* The :func:`int` and :func:`long` types gained a ``bit_length``
|
||||
method that returns the number of bits necessary to represent
|
||||
its argument in binary::
|
||||
|
@ -106,7 +123,7 @@ Some smaller changes made to the core Python language are:
|
|||
(Contributed by Fredrik Johansson and Victor Stinner; :issue:`3439`.)
|
||||
|
||||
* The :class:`bytearray` type's :meth:`translate` method will
|
||||
now accept None as its first argument. (Fixed by Georg Brandl;
|
||||
now accept ``None`` as its first argument. (Fixed by Georg Brandl;
|
||||
:issue:`4759`.)
|
||||
|
||||
.. ======================================================================
|
||||
|
@ -201,7 +218,7 @@ changes, or look through the Subversion logs for all the details.
|
|||
management protocol, so you can write ``with bz2.BZ2File(...) as f: ...``.
|
||||
(Contributed by Hagen Fuerstenau; :issue:`3860`.)
|
||||
|
||||
* A new :class:`Counter` class in the :mod:`collections` module is
|
||||
* New class: the :class:`Counter` class in the :mod:`collections` module is
|
||||
useful for tallying data. :class:`Counter` instances behave mostly
|
||||
like dictionaries but return zero for missing keys instead of
|
||||
raising a :exc:`KeyError`::
|
||||
|
@ -236,7 +253,7 @@ changes, or look through the Subversion logs for all the details.
|
|||
Contributed by Raymond Hettinger; :issue:`1696199`.
|
||||
|
||||
The :class:`namedtuple` class now has an optional *rename* parameter.
|
||||
If *rename* is True, field names that are invalid because they've
|
||||
If *rename* is true, field names that are invalid because they've
|
||||
been repeated or that aren't legal Python identifiers will be
|
||||
renamed to legal names that are derived from the field's
|
||||
position within the list of fields:
|
||||
|
@ -247,8 +264,13 @@ changes, or look through the Subversion logs for all the details.
|
|||
|
||||
(Added by Raymond Hettinger; :issue:`1818`.)
|
||||
|
||||
The :class:`deque` data type now exposes its maximum length as the
|
||||
read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.)
|
||||
|
||||
* In Distutils, :func:`distutils.sdist.add_defaults` now uses
|
||||
*package_dir* and *data_files* to create the MANIFEST file.
|
||||
:mod:`distutils.sysconfig` will now read the :envvar:`AR`
|
||||
environment variable.
|
||||
|
||||
It is no longer mandatory to store clear-text passwords in the
|
||||
:file:`.pypirc` file when registering and uploading packages to PyPI. As long
|
||||
|
@ -256,6 +278,12 @@ changes, or look through the Subversion logs for all the details.
|
|||
prompt for the password if not present. (Added by Tarek Ziade,
|
||||
based on an initial contribution by Nathan Van Gheem; :issue:`4394`.)
|
||||
|
||||
A Distutils setup can now specify that a C extension is optional by
|
||||
setting the *optional* option setting to true. If this optional is
|
||||
supplied, failure to build the extension will not abort the build
|
||||
process, but instead simply not install the failing extension.
|
||||
(Contributed by Georg Brandl; :issue:`5583`.)
|
||||
|
||||
* New method: the :class:`Decimal` class gained a
|
||||
:meth:`from_float` class method that performs an exact conversion
|
||||
of a floating-point number to a :class:`Decimal`.
|
||||
|
@ -267,8 +295,8 @@ changes, or look through the Subversion logs for all the details.
|
|||
``Decimal('0.1000000000000000055511151231257827021181583404541015625')``.
|
||||
(Implemented by Raymond Hettinger; :issue:`4796`.)
|
||||
|
||||
* A new function in the :mod:`gc` module, :func:`is_tracked`, returns
|
||||
True if a given instance is tracked by the garbage collector, False
|
||||
* New function: the :mod:`gc` module's :func:`is_tracked` returns
|
||||
true if a given instance is tracked by the garbage collector, false
|
||||
otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.)
|
||||
|
||||
* The :mod:`gzip` module's :class:`GzipFile` now supports the context
|
||||
|
@ -284,7 +312,7 @@ changes, or look through the Subversion logs for all the details.
|
|||
|
||||
* New function: ``itertools.compress(*data*, *selectors*)`` takes two
|
||||
iterators. Elements of *data* are returned if the corresponding
|
||||
value in *selectors* is True::
|
||||
value in *selectors* is true::
|
||||
|
||||
itertools.compress('ABCDEF', [1,0,1,0,1,1]) =>
|
||||
A, C, E, F
|
||||
|
@ -322,12 +350,22 @@ changes, or look through the Subversion logs for all the details.
|
|||
with any object literal that decodes to a list of pairs.
|
||||
(Contributed by Raymond Hettinger; :issue:`5381`.)
|
||||
|
||||
* The :mod:`multiprocessing` module's :class:`Manager*` classes
|
||||
can now be passed a callable that will be called whenever
|
||||
a subprocess is started, along with a set of arguments that will be
|
||||
passed to the callable.
|
||||
(Contributed by lekma; :issue:`5585`.)
|
||||
|
||||
* The :mod:`pydoc` module now has help for the various symbols that Python
|
||||
uses. You can now do ``help('<<')`` or ``help('@')``, for example.
|
||||
(Contributed by David Laban; :issue:`4739`.)
|
||||
|
||||
* A new function in the :mod:`subprocess` module,
|
||||
:func:`check_output`, runs a command with a specified set of arguments
|
||||
* The :mod:`re` module's :func:`split`, :func:`sub`, and :func:`subn`
|
||||
now accept an optional *flags* argument, for consistency with the
|
||||
other functions in the module. (Added by Gregory P. Smith.)
|
||||
|
||||
* New function: the :mod:`subprocess` module's
|
||||
:func:`check_output` runs a command with a specified set of arguments
|
||||
and returns the command's output as a string when the command runs without
|
||||
error, or raises a :exc:`CalledProcessError` exception otherwise.
|
||||
|
||||
|
@ -343,26 +381,99 @@ changes, or look through the Subversion logs for all the details.
|
|||
|
||||
(Contributed by Gregory P. Smith.)
|
||||
|
||||
* New function: :func:`is_declared_global` in the :mod:`symtable` module
|
||||
returns true for variables that are explicitly declared to be global,
|
||||
false for ones that are implicitly global.
|
||||
(Contributed by Jeremy Hylton.)
|
||||
|
||||
* The ``sys.version_info`` value is now a named tuple, with attributes
|
||||
named ``major``, ``minor``, ``micro``, ``releaselevel``, and ``serial``.
|
||||
(Contributed by Ross Light; :issue:`4285`.)
|
||||
|
||||
* The :mod:`threading` module's :meth:`Event.wait` method now returns
|
||||
the internal flag on exit. This means the method will usually
|
||||
return true because :meth:`wait` is supposed to block until the
|
||||
internal flag becomes true. The return value will only be false if
|
||||
a timeout was provided and the operation timed out.
|
||||
(Contributed by XXX; :issue:`1674032`.)
|
||||
|
||||
* The :mod:`unittest` module was enhanced in several ways.
|
||||
The progress messages will now show 'x' for expected failures
|
||||
and 'u' for unexpected successes when run in verbose mode.
|
||||
(Contributed by Benjamin Peterson.)
|
||||
Test cases can raise the :exc:`SkipTest` exception to skip a test.
|
||||
(:issue:`1034053`.)
|
||||
It will now use 'x' for expected failures
|
||||
and 'u' for unexpected successes when run in its verbose mode.
|
||||
(Contributed by Benjamin Peterson.)
|
||||
|
||||
The error messages for :meth:`assertEqual`,
|
||||
:meth:`assertTrue`, and :meth:`assertFalse`
|
||||
failures now provide more information. If you set the
|
||||
:attr:`longMessage` attribute of your :class:`TestCase` classes to
|
||||
true, both the standard error message and any additional message you
|
||||
provide will be printed for failures. (Added by Michael Foord; :issue:`5663`.)
|
||||
|
||||
The :meth:`assertRaises` and :meth:`failUnlessRaises` methods now
|
||||
return a context handler when called without providing a callable
|
||||
object to run. For example, you can write this::
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
raise ValueError
|
||||
with self.assertRaises(KeyError):
|
||||
raise ValueError
|
||||
|
||||
(Implemented by Antoine Pitrou; :issue:`4444`.)
|
||||
|
||||
A number of new methods were added that provide more specialized
|
||||
tests. Many of these methods were written by Google engineers
|
||||
for use in their test suites; Gregory P. Smith, Michael Foord, and
|
||||
GvR worked on merging them into Python's version of :mod:`unittest`.
|
||||
|
||||
* :meth:`assertIsNone` and :meth:`assertIsNotNone` take one
|
||||
expression and verify that the result is or is not ``None``.
|
||||
|
||||
* :meth:`assertIs` and :meth:`assertIsNot` take two values and check
|
||||
whether the two values evaluate to the same object or not.
|
||||
(Added by Michael Foord; :issue:`2578`.)
|
||||
|
||||
* :meth:`assertGreater`, :meth:`assertGreaterEqual`,
|
||||
:meth:`assertLess`, and :meth:`assertLessEqual` compare
|
||||
two quantities.
|
||||
|
||||
* :meth:`assertMultiLineEqual` compares two strings, and if they're
|
||||
not equal, displays a helpful comparison that highlights the
|
||||
differences in the two strings.
|
||||
|
||||
* :meth:`assertRegexpMatches` checks whether its first argument is a
|
||||
string matching a regular expression provided as its second argument.
|
||||
|
||||
* :meth:`assertRaisesRegexp` checks whether a particular exception
|
||||
is raised, and then also checks that the string representation of
|
||||
the exception matches the provided regular expression.
|
||||
|
||||
* :meth:`assertIn` and :meth:`assertNotIn` tests whether
|
||||
*first* is or is not in *second*.
|
||||
|
||||
* :meth:`assertSameElements` tests whether two provided sequences
|
||||
contain the same elements.
|
||||
|
||||
* :meth:`assertSetEqual` compares whether two sets are equal, and
|
||||
only reports the differences between the sets in case of error.
|
||||
|
||||
* Similarly, :meth:`assertListEqual` and :meth:`assertTupleEqual`
|
||||
compare the specified types and explain the differences.
|
||||
More generally, :meth:`assertSequenceEqual` compares two sequences
|
||||
and can optionally check whether both sequences are of a
|
||||
particular type.
|
||||
|
||||
* :meth:`assertDictEqual` compares two dictionaries and reports the
|
||||
differences. :meth:`assertDictContainsSubset` checks whether
|
||||
all of the key/value pairs in *first* are found in *second*.
|
||||
|
||||
* A new hook, :meth:`addTypeEqualityFunc` takes a type object and a
|
||||
function. The :meth:`assertEqual` method will use the function
|
||||
when both of the objects being compared are of the specified type.
|
||||
This function should compare the two objects and raise an
|
||||
exception if they don't match; it's a good idea for the function
|
||||
to provide additional information about why the two objects are
|
||||
matching, much as the new sequence comparison methods do.
|
||||
|
||||
* The :func:`is_zipfile` function in the :mod:`zipfile` module will now
|
||||
accept a file object, in addition to the path names accepted in earlier
|
||||
versions. (Contributed by Gabriel Genellina; :issue:`4756`.)
|
||||
|
@ -376,7 +487,37 @@ changes, or look through the Subversion logs for all the details.
|
|||
importlib: Importing Modules
|
||||
------------------------------
|
||||
|
||||
XXX write this
|
||||
Python 3.1 includes the :mod:`importlib` package, a re-implementation
|
||||
of the logic underlying Python's :keyword:`import` statement.
|
||||
:mod:`importlib` is useful for implementors of Python interpreters and
|
||||
to user who wish to write new importers that can participate in the
|
||||
import process. Python 2.7 doesn't contain the complete
|
||||
:mod:`importlib` package, but instead has a tiny subset that contains
|
||||
a single function, :func:`import_module`.
|
||||
|
||||
``import_module(*name*, *package*=None)`` imports a module. *name* is
|
||||
a string containing the module or package's name. It's possible to do
|
||||
relative imports by providing a string that begins with a ``.``
|
||||
character, such as ``..utils.errors``. For relative imports, the
|
||||
*package* argument must be provided and is the name of the package that
|
||||
will be used as the anchor for
|
||||
the relative import. :func:`import_module` both inserts the imported
|
||||
module into ``sys.modules`` and returns the module object.
|
||||
|
||||
Here are some examples::
|
||||
|
||||
>>> from importlib import import_module
|
||||
>>> anydbm = import_module('anydbm') # Standard absolute import
|
||||
>>> anydbm
|
||||
<module 'anydbm' from '/p/python/Lib/anydbm.py'>
|
||||
>>> # Relative import
|
||||
>>> sysconfig = import_module('..sysconfig', 'distutils.command')
|
||||
>>> sysconfig
|
||||
<module 'distutils.sysconfig' from '/p/python/Lib/distutils/sysconfig.pyc'>
|
||||
|
||||
:mod:`importlib` was implemented by Brett Cannon and introduced in
|
||||
Python 3.1.
|
||||
|
||||
|
||||
ttk: Themed Widgets for Tk
|
||||
--------------------------
|
||||
|
|
|
@ -23,6 +23,7 @@ __all__ = ['build',
|
|||
'bdist_rpm',
|
||||
'bdist_wininst',
|
||||
'check',
|
||||
'upload',
|
||||
# These two are reserved for future use:
|
||||
#'bdist_sdux',
|
||||
#'bdist_pkgtool',
|
||||
|
|
|
@ -27,8 +27,9 @@ try:
|
|||
self.messages.append((level, message, children, kwargs))
|
||||
|
||||
HAS_DOCUTILS = True
|
||||
except ImportError:
|
||||
# docutils is not installed
|
||||
except Exception:
|
||||
# Catch all exceptions because exceptions besides ImportError probably
|
||||
# indicate that docutils is not ported to Py3k.
|
||||
HAS_DOCUTILS = False
|
||||
|
||||
class check(Command):
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
"""Tests for distutils.spawn."""
|
||||
import unittest
|
||||
from distutils.spawn import _nt_quote_args
|
||||
|
||||
class SpawnTestCase(unittest.TestCase):
|
||||
|
||||
def test_nt_quote_args(self):
|
||||
|
||||
for (args, wanted) in ((['with space', 'nospace'],
|
||||
['"with space"', 'nospace']),
|
||||
(['nochange', 'nospace'],
|
||||
['nochange', 'nospace'])):
|
||||
res = _nt_quote_args(args)
|
||||
self.assertEquals(res, wanted)
|
||||
|
||||
def test_suite():
|
||||
return unittest.makeSuite(SpawnTestCase)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(defaultTest="test_suite")
|
|
@ -478,12 +478,15 @@ class BaseManager(object):
|
|||
dispatch(conn, None, 'dummy')
|
||||
self._state.value = State.STARTED
|
||||
|
||||
def start(self):
|
||||
def start(self, initializer=None, initargs=()):
|
||||
'''
|
||||
Spawn a server process for this manager object
|
||||
'''
|
||||
assert self._state.value == State.INITIAL
|
||||
|
||||
if initializer is not None and not hasattr(initializer, '__call__'):
|
||||
raise TypeError('initializer must be a callable')
|
||||
|
||||
# pipe over which we will retrieve address of server
|
||||
reader, writer = connection.Pipe(duplex=False)
|
||||
|
||||
|
@ -491,7 +494,7 @@ class BaseManager(object):
|
|||
self._process = Process(
|
||||
target=type(self)._run_server,
|
||||
args=(self._registry, self._address, self._authkey,
|
||||
self._serializer, writer),
|
||||
self._serializer, writer, initializer, initargs),
|
||||
)
|
||||
ident = ':'.join(str(i) for i in self._process._identity)
|
||||
self._process.name = type(self).__name__ + '-' + ident
|
||||
|
@ -512,10 +515,14 @@ class BaseManager(object):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def _run_server(cls, registry, address, authkey, serializer, writer):
|
||||
def _run_server(cls, registry, address, authkey, serializer, writer,
|
||||
initializer=None, initargs=()):
|
||||
'''
|
||||
Create a server, report its address and run it
|
||||
'''
|
||||
if initializer is not None:
|
||||
initializer(*initargs)
|
||||
|
||||
# create server
|
||||
server = cls._Server(registry, address, authkey, serializer)
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ class Pool(object):
|
|||
except NotImplementedError:
|
||||
processes = 1
|
||||
|
||||
if initializer is not None and not hasattr(initializer, '__call__'):
|
||||
raise TypeError('initializer must be a callable')
|
||||
|
||||
self._pool = []
|
||||
for i in range(processes):
|
||||
w = self.Process(
|
||||
|
|
|
@ -1832,7 +1832,37 @@ class OtherTest(unittest.TestCase):
|
|||
multiprocessing.connection.answer_challenge,
|
||||
_FakeConnection(), b'abc')
|
||||
|
||||
testcases_other = [OtherTest, TestInvalidHandle]
|
||||
#
|
||||
# Test Manager.start()/Pool.__init__() initializer feature - see issue 5585
|
||||
#
|
||||
|
||||
def initializer(ns):
|
||||
ns.test += 1
|
||||
|
||||
class TestInitializers(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mgr = multiprocessing.Manager()
|
||||
self.ns = self.mgr.Namespace()
|
||||
self.ns.test = 0
|
||||
|
||||
def tearDown(self):
|
||||
self.mgr.shutdown()
|
||||
|
||||
def test_manager_initializer(self):
|
||||
m = multiprocessing.managers.SyncManager()
|
||||
self.assertRaises(TypeError, m.start, 1)
|
||||
m.start(initializer, (self.ns,))
|
||||
self.assertEqual(self.ns.test, 1)
|
||||
m.shutdown()
|
||||
|
||||
def test_pool_initializer(self):
|
||||
self.assertRaises(TypeError, multiprocessing.Pool, initializer=1)
|
||||
p = multiprocessing.Pool(1, initializer, (self.ns,))
|
||||
p.close()
|
||||
p.join()
|
||||
self.assertEqual(self.ns.test, 1)
|
||||
|
||||
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers]
|
||||
|
||||
#
|
||||
#
|
||||
|
|
|
@ -2311,6 +2311,16 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
|
|||
# from this TestCase instance but since its a local nothing else
|
||||
# will ever notice that.
|
||||
|
||||
def testAssertIs(self):
|
||||
thing = object()
|
||||
self.assertIs(thing, thing)
|
||||
self.assertRaises(self.failureException, self.assertIs, thing, object())
|
||||
|
||||
def testAssertIsNot(self):
|
||||
thing = object()
|
||||
self.assertIsNot(thing, object())
|
||||
self.assertRaises(self.failureException, self.assertIsNot, thing, thing)
|
||||
|
||||
def testAssertIn(self):
|
||||
animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}
|
||||
|
||||
|
@ -2454,6 +2464,7 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
|
|||
|
||||
# Test that sequences of unhashable objects can be tested for sameness:
|
||||
self.assertSameElements([[1, 2], [3, 4]], [[3, 4], [1, 2]])
|
||||
|
||||
self.assertSameElements([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
|
||||
self.assertRaises(self.failureException, self.assertSameElements,
|
||||
[[1]], [[2]])
|
||||
|
@ -2988,6 +2999,18 @@ class TestLongMessage(TestCase):
|
|||
"^unexpectedly None$",
|
||||
"^unexpectedly None : oops$"])
|
||||
|
||||
def testAssertIs(self):
|
||||
self.assertMessages('assertIs', (None, 'foo'),
|
||||
["^None is not 'foo'$", "^oops$",
|
||||
"^None is not 'foo'$",
|
||||
"^None is not 'foo' : oops$"])
|
||||
|
||||
def testAssertIsNot(self):
|
||||
self.assertMessages('assertIsNot', (None, None),
|
||||
["^unexpectedly identical: None$", "^oops$",
|
||||
"^unexpectedly identical: None$",
|
||||
"^unexpectedly identical: None : oops$"])
|
||||
|
||||
|
||||
######################################################################
|
||||
## Main
|
||||
|
|
|
@ -807,6 +807,18 @@ class TestCase(object):
|
|||
standardMsg = '%r unexpectedly found in %r' % (member, container)
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
def assertIs(self, expr1, expr2, msg=None):
|
||||
"""Just like self.assertTrue(a is b), but with a nicer default message."""
|
||||
if expr1 is not expr2:
|
||||
standardMsg = '%r is not %r' % (expr1, expr2)
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
def assertIsNot(self, expr1, expr2, msg=None):
|
||||
"""Just like self.assertTrue(a is not b), but with a nicer default message."""
|
||||
if expr1 is expr2:
|
||||
standardMsg = 'unexpectedly identical: %r' % (expr1,)
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
def assertDictEqual(self, d1, d2, msg=None):
|
||||
self.assert_(isinstance(d1, dict), 'First argument is not a dictionary')
|
||||
self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
|
||||
|
@ -1020,7 +1032,7 @@ class TestSuite(object):
|
|||
self.addTests(tests)
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s tests=%s>" % (_strclass(self.__class__), self._tests)
|
||||
return "<%s tests=%s>" % (_strclass(self.__class__), list(self))
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, self.__class__):
|
||||
|
@ -1035,7 +1047,7 @@ class TestSuite(object):
|
|||
|
||||
def countTestCases(self):
|
||||
cases = 0
|
||||
for test in self._tests:
|
||||
for test in self:
|
||||
cases += test.countTestCases()
|
||||
return cases
|
||||
|
||||
|
@ -1055,7 +1067,7 @@ class TestSuite(object):
|
|||
self.addTest(test)
|
||||
|
||||
def run(self, result):
|
||||
for test in self._tests:
|
||||
for test in self:
|
||||
if result.shouldStop:
|
||||
break
|
||||
test(result)
|
||||
|
@ -1066,7 +1078,7 @@ class TestSuite(object):
|
|||
|
||||
def debug(self):
|
||||
"""Run the tests without collecting errors in a TestResult"""
|
||||
for test in self._tests:
|
||||
for test in self:
|
||||
test.debug()
|
||||
|
||||
|
||||
|
|
|
@ -841,6 +841,7 @@ LIBSUBDIRS= tkinter site-packages test test/output test/data \
|
|||
sqlite3 sqlite3/test \
|
||||
logging bsddb bsddb/test csv wsgiref urllib \
|
||||
lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
|
||||
lib2to3/tests/data lib2to3/tests/data/fixes lib2to3/tests/data/fixers/myfixes \
|
||||
ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
|
||||
distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
|
||||
importlib importlib/test importlib/test/builtin \
|
||||
|
@ -908,11 +909,13 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
|
|||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST) -f \
|
||||
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
|
||||
-x 'bad_coding|badsyntax|site-packages|py2_test_grammar' \
|
||||
$(DESTDIR)$(LIBDEST)
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST) -f \
|
||||
-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
|
||||
-x 'bad_coding|badsyntax|site-packages|py2_test_grammar' \
|
||||
$(DESTDIR)$(LIBDEST)
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST)/site-packages -f \
|
||||
|
|
|
@ -21,6 +21,7 @@ PURIFY.README Information for Purify users
|
|||
pymemcompat.h Memory interface compatibility file.
|
||||
python.man UNIX man page for the python interpreter
|
||||
python-mode.el Emacs mode for editing Python programs
|
||||
python-wing.wpr Wing IDE project file
|
||||
README The file you're reading now
|
||||
README.valgrind Information for Valgrind users, see valgrind-python.supp
|
||||
RFD Request For Discussion about a Python newsgroup
|
||||
|
|
13
Misc/gdbinit
13
Misc/gdbinit
|
@ -138,3 +138,16 @@ define pystackv
|
|||
end
|
||||
select-frame 0
|
||||
end
|
||||
|
||||
# generally useful macro to print a Unicode string
|
||||
def pu
|
||||
set $uni = $arg0
|
||||
set $i = 0
|
||||
while (*$uni && $i++<100)
|
||||
if (*$uni < 0x80)
|
||||
print *(char*)$uni++
|
||||
else
|
||||
print /x *(short*)$uni++
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!wing
|
||||
#!version=3.0
|
||||
##################################################################
|
||||
# Wing IDE project file #
|
||||
##################################################################
|
||||
[project attributes]
|
||||
proj.directory-list = [{'dirloc': loc('..'),
|
||||
'excludes': (),
|
||||
'filter': '*',
|
||||
'include_hidden': False,
|
||||
'recursive': True,
|
||||
'watch_for_changes': True}]
|
||||
proj.file-type = 'shared'
|
Loading…
Reference in New Issue