Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added newline before contract description #31

Merged
merged 1 commit into from
Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_icontract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _format_contract(contract: icontract._Contract) -> Lines:
doc = None

if doc is not None:
result = condition_lines + Lines(["({})".format(doc)])
result = condition_lines + Lines(["", "({})".format(doc)])
else:
result = condition_lines

Expand Down
13 changes: 13 additions & 0 deletions tests/test_sphinx_icontract.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def resolve_initial_paths(initial_paths: List[pathlib.Path]) -> List[pathlib.Pat
# yapf: disable
':ensures:',
' * :code:`all(pth in result for pth in initial_paths if pth.is_file())`',
'',
' (Initial files also in result)'
# yapf: enable
],
Expand Down Expand Up @@ -395,9 +396,11 @@ def some_func(x: int) -> int:
# yapf: disable
':requires:',
' * :code:`x > 0`',
'',
' (some precondition)',
':ensures:',
' * :code:`result >= x`',
'',
' (some postcondition)'
# yapf: enable
],
Expand Down Expand Up @@ -474,6 +477,7 @@ def some_getter(self) -> int:
# yapf: disable
':establishes:',
' * :code:`self.some_getter() > 0`',
'',
' (some invariant)'
# yapf: enable
],
Expand Down Expand Up @@ -637,6 +641,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (x positive; raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -656,6 +661,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (Raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -673,6 +679,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (x positive; raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -693,6 +700,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :py:func:`must_be_positive`',
'',
' (x positive; raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -714,6 +722,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (x positive; raise :py:class:`SomeClass.SomeError`)'
],
lines)
Expand All @@ -732,6 +741,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (x must be positive; raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -749,6 +759,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (Raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -769,6 +780,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :py:func:`must_be_positive`',
'',
' (Raise :py:class:`ValueError`)'
],
lines)
Expand All @@ -787,6 +799,7 @@ def some_func(x: int) -> None:
[
':requires:',
' * :code:`x > 0`',
'',
' (x must be positive; raise :py:class:`ValueError`)'
],
lines)
Expand Down