@@ -42,6 +42,11 @@ can be customized by end users easily.
42
42
be used for this purpose.
43
43
44
44
45
+ .. testsetup ::
46
+
47
+ import configparser
48
+
49
+
45
50
Quick Start
46
51
-----------
47
52
@@ -95,7 +100,6 @@ back and explore the data it holds.
95
100
96
101
.. doctest ::
97
102
98
- >>> import configparser
99
103
>>> config = configparser.ConfigParser()
100
104
>>> config.sections()
101
105
[]
@@ -116,8 +120,8 @@ back and explore the data it holds.
116
120
'no'
117
121
>>> topsecret[' Port' ]
118
122
'50022'
119
- >>> for key in config[' bitbucket.org' ]: print (key)
120
- ...
123
+ >>> for key in config[' bitbucket.org' ]: # doctest: +SKIP
124
+ ... print (key)
121
125
user
122
126
compressionlevel
123
127
serveraliveinterval
@@ -469,9 +473,9 @@ the :meth:`__init__` options:
469
473
... ' bar' : ' y' ,
470
474
... ' baz' : ' z' }
471
475
... })
472
- >>> parser.sections()
476
+ >>> parser.sections() # doctest: +SKIP
473
477
['section3', 'section2', 'section1']
474
- >>> [option for option in parser[' section3' ]]
478
+ >>> [option for option in parser[' section3' ]] # doctest: +SKIP
475
479
['baz', 'foo', 'bar']
476
480
477
481
In these operations you need to use an ordered dictionary as well:
@@ -498,11 +502,11 @@ the :meth:`__init__` options:
498
502
... ),
499
503
... ))
500
504
... )
501
- >>> parser.sections()
505
+ >>> parser.sections() # doctest: +SKIP
502
506
['s1', 's2']
503
- >>> [option for option in parser[' s1' ]]
507
+ >>> [option for option in parser[' s1' ]] # doctest: +SKIP
504
508
['1', '3', '5']
505
- >>> [option for option in parser[' s2' ].values()]
509
+ >>> [option for option in parser[' s2' ].values()] # doctest: +SKIP
506
510
['b', 'd', 'f']
507
511
508
512
* *allow_no_value *, default value: ``False ``
@@ -597,11 +601,11 @@ the :meth:`__init__` options:
597
601
... line #3
598
602
... """)
599
603
>>> print(parser['hashes']['shebang'])
600
-
604
+ <BLANKLINE>
601
605
#!/usr/bin/env python
602
606
# -*- coding: utf-8 -*-
603
607
>>> print(parser['hashes']['extensions'])
604
-
608
+ <BLANKLINE>
605
609
enabled_extension
606
610
another_extension
607
611
yet_another_extension
@@ -755,18 +759,19 @@ be overridden by subclasses or by attribute assignment.
755
759
756
760
.. doctest ::
757
761
762
+ >>> import re
758
763
>>> config = """
759
764
... [Section 1 ]
760
765
... option = value
761
766
...
762
767
... [ Section 2 ]
763
768
... another = val
764
769
... """
765
- >>> typical = ConfigParser()
770
+ >>> typical = configparser. ConfigParser()
766
771
>>> typical.read_string(config)
767
772
>>> typical.sections()
768
773
['Section 1', ' Section 2 ']
769
- >>> custom = ConfigParser()
774
+ >>> custom = configparser. ConfigParser()
770
775
>>> custom.SECTCRE = re.compile(r " \[ * ( ?P<header> [^ ] ]+? ) * \] " )
771
776
>>> custom.read_string(config)
772
777
>>> custom.sections()
0 commit comments