1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import textwrap
from reno._exts import show_reno_config
from reno import config
from reno.tests import base
class TestMultiLineString(base.TestCase):
def test_no_indent(self):
input = textwrap.dedent("""\
The notes subdirectory within the relnotesdir where the
notes live.
""")
expected = '\n'.join([
'The notes subdirectory within the relnotesdir where the',
'notes live.',
])
actual = '\n'.join(show_reno_config._multi_line_string(input))
self.assertEqual(expected, actual)
def test_with_indent(self):
input = textwrap.dedent("""\
The notes subdirectory within the relnotesdir where the
notes live.
""")
expected = '\n'.join([
' The notes subdirectory within the relnotesdir where the',
' notes live.',
])
actual = '\n'.join(show_reno_config._multi_line_string(input, ' '))
self.assertEqual(expected, actual)
def test_first_line_blank(self):
input = textwrap.dedent("""
The notes subdirectory within the relnotesdir where the
notes live.
""")
expected = '\n'.join([
' The notes subdirectory within the relnotesdir where the',
' notes live.',
])
actual = '\n'.join(show_reno_config._multi_line_string(input, ' '))
self.assertEqual(expected, actual)
class TestFormatOptionHelp(base.TestCase):
def test_simple_default(self):
opt = config.Opt(
'notesdir', 'path/to/notes',
textwrap.dedent("""\
The notes subdirectory within the relnotesdir where the
notes live.
"""),
)
actual = '\n'.join(show_reno_config._format_option_help([opt]))
expected = textwrap.dedent("""\
``notesdir``
The notes subdirectory within the relnotesdir where the
notes live.
Defaults to ``'path/to/notes'``
""")
self.assertEqual(expected, actual)
def test_bool_default(self):
opt = config.Opt(
'collapse_pre_releases', True,
textwrap.dedent("""\
Should pre-release versions be merged into the final release
of the same number (1.0.0.0a1 notes appear under 1.0.0).
"""),
)
actual = '\n'.join(show_reno_config._format_option_help([opt]))
expected = textwrap.dedent("""\
``collapse_pre_releases``
Should pre-release versions be merged into the final release
of the same number (1.0.0.0a1 notes appear under 1.0.0).
Defaults to ``True``
""")
self.assertEqual(expected, actual)
def test_multiline_default(self):
opt = config.Opt(
'release_tag_re',
textwrap.dedent('''\
((?:[\\d.ab]|rc)+) # digits, a, b, and rc cover regular and
# pre-releases
'''),
textwrap.dedent("""\
The regex pattern used to match the repo tags representing a
valid release version. The pattern is compiled with the
verbose and unicode flags enabled.
"""),
)
actual = '\n'.join(show_reno_config._format_option_help([opt]))
expected = textwrap.dedent("""\
``release_tag_re``
The regex pattern used to match the repo tags representing a
valid release version. The pattern is compiled with the
verbose and unicode flags enabled.
Defaults to
::
((?:[\\d.ab]|rc)+) # digits, a, b, and rc cover regular and
# pre-releases
""")
self.assertEqual(expected, actual)
|