diff -r 3d328ee18612 Doc/library/configparser.rst --- a/Doc/library/configparser.rst Mon Jan 30 13:56:20 2017 +0300 +++ b/Doc/library/configparser.rst Mon Jan 30 14:06:28 2017 +0100 @@ -42,6 +42,11 @@ be used for this purpose. +.. testsetup:: + + import configparser + + Quick Start ----------- @@ -95,7 +100,6 @@ .. doctest:: - >>> import configparser >>> config = configparser.ConfigParser() >>> config.sections() [] @@ -116,13 +120,13 @@ 'no' >>> topsecret['Port'] '50022' - >>> for key in config['bitbucket.org']: print(key) - ... + >>> for key in sorted(config['bitbucket.org']): + ... print(key) + compression + compressionlevel + forwardx11 + serveraliveinterval user - compressionlevel - serveraliveinterval - compression - forwardx11 >>> config['bitbucket.org']['ForwardX11'] 'yes' @@ -469,10 +473,10 @@ ... 'bar': 'y', ... 'baz': 'z'} ... }) - >>> parser.sections() - ['section3', 'section2', 'section1'] - >>> [option for option in parser['section3']] - ['baz', 'foo', 'bar'] + >>> sorted(parser.sections()) + ['section1', 'section2', 'section3'] + >>> sorted(option for option in parser['section3']) + ['bar', 'baz', 'foo'] In these operations you need to use an ordered dictionary as well: @@ -498,11 +502,11 @@ ... ), ... )) ... ) - >>> parser.sections() + >>> sorted(parser.sections()) ['s1', 's2'] - >>> [option for option in parser['s1']] + >>> sorted([option for option in parser['s1']]) ['1', '3', '5'] - >>> [option for option in parser['s2'].values()] + >>> sorted([option for option in parser['s2'].values()]) ['b', 'd', 'f'] * *allow_no_value*, default value: ``False`` @@ -597,11 +601,11 @@ ... line #3 ... """) >>> print(parser['hashes']['shebang']) - + #!/usr/bin/env python # -*- coding: utf-8 -*- >>> print(parser['hashes']['extensions']) - + enabled_extension another_extension yet_another_extension @@ -755,6 +759,7 @@ .. doctest:: + >>> import re >>> config = """ ... [Section 1] ... option = value @@ -762,11 +767,11 @@ ... [ Section 2 ] ... another = val ... """ - >>> typical = ConfigParser() + >>> typical = configparser.ConfigParser() >>> typical.read_string(config) >>> typical.sections() ['Section 1', ' Section 2 '] - >>> custom = ConfigParser() + >>> custom = configparser.ConfigParser() >>> custom.SECTCRE = re.compile(r"\[ *(?P
[^]]+?) *\]") >>> custom.read_string(config) >>> custom.sections() diff -r 3d328ee18612 Doc/library/copyreg.rst --- a/Doc/library/copyreg.rst Mon Jan 30 13:56:20 2017 +0300 +++ b/Doc/library/copyreg.rst Mon Jan 30 14:06:28 2017 +0100 @@ -59,7 +59,7 @@ ... >>> copyreg.pickle(C, pickle_c) >>> c = C(1) - >>> d = copy.copy(c) + >>> d = copy.copy(c) # doctest: +SKIP pickling a C instance... - >>> p = pickle.dumps(c) + >>> p = pickle.dumps(c) # doctest: +SKIP pickling a C instance... diff -r 3d328ee18612 Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst Mon Jan 30 13:56:20 2017 +0300 +++ b/Doc/library/ctypes.rst Mon Jan 30 14:06:28 2017 +0100 @@ -1408,6 +1408,10 @@ accessing it repeatedly returns the same object each time. On the other hand, accessing it through an index returns a new object each time: +.. doctest:: + + >>> from ctypes import CDLL + >>> libc = CDLL("libc.so.6") # On Linux >>> libc.time == libc.time True >>> libc['time'] == libc['time']