Changeset - 3d3c7481aede
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2020-04-22 16:21:23
mads@kiilerich.com
Grafted from: 83ce7e84980a
inifile: add doctest coverage of comment corner cases

Shows room for improvement - doesn't show any bugs.
1 file changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/inifile.py
Show inline comments
 
@@ -64,17 +64,28 @@ def expand(template, mako_variable_value
 
    ... [second-section]
 
    ... %if conditional_options == 'option-a':
 
    ... # option a was chosen
 
    ... %elif conditional_options == 'option-b':
 
    ... some_variable = "never mind - option-b will not be used anyway ..."
 
    ... %endif
 
    ...
 
    ... [comment-section]
 
    ... #variable3 = 3.0
 
    ... #variable4 = 4.0
 
    ... #variable5 = 5.0
 
    ... variable5 = 5.1
 
    ... #variable6 = 6.0
 
    ... #variable6 = 6.1
 
    ... #variable7 = 7.0
 
    ... variable7 = 7.1
 
    ... '''
 
    >>> mako_variable_values = {'mako_variable': 'VALUE', 'mako_function': (lambda: 'FUNCTION RESULT'),
 
    ...                         'conditional_options': 'option-a', 'http_server': 'nc'}
 
    >>> settings = { # only partially used
 
    ...     '[first-section]': {'variable2': 'VAL2', 'first_extra': 'EXTRA'},
 
    ...     '[comment-section]': {'variable3': '3.0', 'variable4': '4.1', 'variable5': '5.2', 'variable6': '6.2', 'variable7': '7.0'},
 
    ...     '[third-section]': {'third_extra': ' 3'},
 
    ...     '[fourth-section]': {'fourth_extra': '4', 'fourth': '"four"'},
 
    ... }
 
    >>> print(expand(template, mako_variable_values, settings))
 
    ERROR: http_server is 'nc' - it should be one of 'waitress', 'gearbox', 'gevent', 'gunicorn', 'uwsgi'
 
    <BLANKLINE>
 
@@ -88,12 +99,28 @@ def expand(template, mako_variable_value
 
    <BLANKLINE>
 
    <BLANKLINE>
 
    # FUNCTION RESULT
 
    [second-section]
 
    # option a was chosen
 
    <BLANKLINE>
 
    [comment-section]
 
    #variable3 = 3.0
 
    #variable4 = 4.0
 
    #variable5 = 5.0
 
    #variable5 = 5.1
 
    variable5 = 5.2
 
    #variable6 = 6.0
 
    #variable6 = 6.1
 
    #variable7 = 7.0
 
    #variable7 = 7.1
 
    variable7 = 7.0
 
    <BLANKLINE>
 
    variable3 = 3.0
 
    variable4 = 4.1
 
    variable6 = 6.2
 
    <BLANKLINE>
 
    [fourth-section]
 
    fourth = "four"
 
    fourth_extra = 4
 
    <BLANKLINE>
 
    [third-section]
 
    third_extra =  3
0 comments (0 inline, 0 general)