Skip to content

Commit

Permalink
test: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
weibullguy committed May 28, 2023
1 parent 9f2a854 commit 2861ffe
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 61 deletions.
7 changes: 5 additions & 2 deletions src/docformatter/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,12 @@ def do_wrap_field_lists( # noqa: PLR0913
initial_indent=indentation,
subsequent_indent=_subsequent,
)
for _idx, _f in enumerate(_wrapped_fields):
for _idx, _wrapped_field in enumerate(_wrapped_fields):
_indent = indentation if _idx == 0 else _subsequent
_wrapped_fields[_idx] = f"{_indent}{re.sub(' +', ' ', _f.strip())}"
_wrapped_fields[
_idx
] = f"{_indent}{re.sub(' +', ' ', _wrapped_field.strip())}"

lines.extend(_wrapped_fields)

text_idx = _field[1]
Expand Down
113 changes: 54 additions & 59 deletions tests/test_docformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_ignore_already_wrapped_link(
@@ -1,6 +1,7 @@
def foo():
"""Description from issue #150 that was being improperly wrapped.
- The text file can be retrieved via the Chrome plugin `Get
- Cookies.txt <https://chrome.google.com/webstore/detail/get-
- cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid>` while browsing."""
Expand Down Expand Up @@ -512,7 +512,7 @@ def test_end_to_end_no_excessive_whitespace(
assert '''\
@@ -1,10 +1,9 @@
"""Create a wrapper around a WiX install.
- :param tools: ToolCache of available tools.
- :param wix_home: The path of the WiX installation.
- :param bin_install: Is the install a binaries-only install? A full
Expand Down Expand Up @@ -576,7 +576,7 @@ def foo():
+
- My list item
- My list item
-
"""
''' == "\n".join(
Expand Down Expand Up @@ -714,7 +714,7 @@ def test_no_pre_summary_space_using_pyproject(
@@ -1,3 +1,2 @@
class TestFoo():
"""Docstring that should not have a pre-summary space."""
-
-
''' == "\n".join(
run_docformatter.communicate()[0].decode().replace("\r", "").split("\n")[2:]
)
Expand All @@ -723,10 +723,10 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
class TestFoo():
"""Docstring that should have a pre-summary space."""
'''
'''\
class TestFoo():
"""Docstring that should have a pre-summary space."""
'''
],
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -761,11 +761,10 @@ def test_pre_summary_space_using_pyproject(
See issue #119.
"""
assert '''\
@@ -1,3 +1,2 @@
class TestFoo():
- """Docstring that should have a pre-summary space."""
-
+ """ Docstring that should have a pre-summary space."""
@@ -1,2 +1,2 @@
class TestFoo():
- """Docstring that should have a pre-summary space."""
+ """ Docstring that should have a pre-summary space."""
''' == "\n".join(
run_docformatter.communicate()[0].decode().replace("\r", "").split("\n")[2:]
)
Expand All @@ -774,13 +773,13 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
class TestFoo():
"""Docstring that should not have a pre-summary newline.
'''\
class TestFoo():
"""Docstring that should not have a pre-summary newline.
This is a multi-line docstring that should not have a
newline placed before the summary."""
'''
This is a multi-line docstring that should not have a
newline placed before the summary."""
'''
],
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -815,17 +814,15 @@ def test_no_pre_summary_newline_using_pyproject(
See issue #119.
"""
assert '''\
@@ -1,6 +1,6 @@
class TestFoo():
"""Docstring that should not have a pre-summary newline.
-
- This is a multi-line docstring that should not have a
- newline placed before the summary."""
-
+
+ This is a multi-line docstring that should not have a
+ newline placed before the summary.
+ """
@@ -1,5 +1,6 @@
class TestFoo():
"""Docstring that should not have a pre-summary newline.
- This is a multi-line docstring that should not have a
- newline placed before the summary."""
+ This is a multi-line docstring that should not have a newline placed
+ before the summary.
+ """
''' == "\n".join(
run_docformatter.communicate()[0].decode().replace("\r", "").split("\n")[2:]
)
Expand Down Expand Up @@ -880,7 +877,7 @@ class TestFoo():
- """Docstring that should have a pre-summary newline.
+ """
+ Docstring that should have a pre-summary newline.
- This is a multi-line docstring that should have a newline
- placed before the summary."""
+ This is a multi-line docstring that should have a newline placed
Expand All @@ -894,11 +891,11 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
class TestFoo():
"""Really long summary docstring that should not be
split into a multiline summary."""
'''
'''\
class TestFoo():
"""Really long summary docstring that should not be
split into a multiline summary."""
'''
],
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -933,13 +930,12 @@ def test_no_pre_summary_multiline_using_pyproject(
See issue #119.
"""
assert '''\
@@ -1,4 +1,3 @@
class TestFoo():
- """Really long summary docstring that should not be
- split into a multiline summary."""
-
+ """Really long summary docstring that should not be split
+ into a multiline summary."""
@@ -1,3 +1,3 @@
class TestFoo():
- """Really long summary docstring that should not be
- split into a multiline summary."""
+ """Really long summary docstring that should not be split into a
+ multiline summary."""
''' == "\n".join(
run_docformatter.communicate()[0].decode().replace("\r", "").split("\n")[2:]
)
Expand All @@ -948,11 +944,11 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
class TestFoo():
"""Really long summary docstring that should be
split into a multiline summary."""
'''
'''\
class TestFoo():
"""Really long summary docstring that should be
split into a multiline summary."""
'''
],
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -987,13 +983,12 @@ def test_pre_summary_multiline_using_pyproject(
See issue #119.
"""
assert '''\
@@ -1,4 +1,3 @@
class TestFoo():
- """Really long summary docstring that should be
- split into a multiline summary."""
-
+ """Really long summary docstring that should be split
+ into a multiline summary."""
@@ -1,3 +1,3 @@
class TestFoo():
- """Really long summary docstring that should be
- split into a multiline summary."""
+ """Really long summary docstring that should be split into a multiline
+ summary."""
''' == "\n".join(
run_docformatter.communicate()[0].decode().replace("\r", "").split("\n")[2:]
)
Expand All @@ -1002,7 +997,7 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
'''\
class TestFoo():
"""Summary docstring that is followed by a description.
Expand Down Expand Up @@ -1047,7 +1042,7 @@ def test_no_blank_using_pyproject(
@@ -1,6 +1,6 @@
class TestFoo():
"""Summary docstring that is followed by a description.
- This is the description and it shouldn\'t have a blank line
- inserted after it.
+ This is the description and it shouldn\'t have a blank line inserted
Expand All @@ -1061,7 +1056,7 @@ class TestFoo():
@pytest.mark.parametrize(
"contents",
[
'''\
'''\
class TestFoo():
"""Summary docstring that is followed by a description.
Expand Down Expand Up @@ -1106,7 +1101,7 @@ def test_blank_using_pyproject(
@@ -1,6 +1,7 @@
class TestFoo():
"""Summary docstring that is followed by a description.
- This is the description and it should have a blank line
- inserted after it.
+ This is the description and it should have a blank line inserted
Expand Down

0 comments on commit 2861ffe

Please sign in to comment.