--- configparser.rst 2016-12-02 23:11:23.161377313 +0100
+++ configparser_new.rst 2016-12-02 23:05:01.445371124 +0100
@@ -68,6 +68,10 @@
:mod:`configparser` classes can read and write such files. Let's start by
creating the above configuration file programmatically.
+.. testsetup::
+
+ import configparser
+
.. doctest::
>>> import configparser
@@ -116,7 +120,7 @@
'no'
>>> topsecret['Port']
'50022'
- >>> for key in config['bitbucket.org']: print(key)
+ >>> for key in config['bitbucket.org']: print(key) # doctest: +SKIP
...
user
compressionlevel
@@ -469,9 +473,9 @@
... 'bar': 'y',
... 'baz': 'z'}
... })
- >>> parser.sections()
+ >>> parser.sections() # doctest: +SKIP
['section3', 'section2', 'section1']
- >>> [option for option in parser['section3']]
+ >>> [option for option in parser['section3']] # doctest: +SKIP
['baz', 'foo', 'bar']
In these operations you need to use an ordered dictionary as well:
@@ -514,8 +518,6 @@
.. doctest::
- >>> import configparser
-
>>> sample_config = """
... [mysqld]
... user = mysql
@@ -571,7 +573,9 @@
values with characters used as comment prefixes. When in doubt, avoid
setting *inline_comment_prefixes*. In any circumstances, the only way of
storing comment prefix characters at the beginning of a line in multiline
- values is to interpolate the prefix, for example::
+ values is to interpolate the prefix, for example:
+
+ .. doctest::
>>> from configparser import ConfigParser, ExtendedInterpolation
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
@@ -597,11 +601,11 @@
... line #3
... """)
>>> print(parser['hashes']['shebang'])
-
+