Skip to content

Commit

Permalink
DocstringMetadata.py: Remove unneeded space
Browse files Browse the repository at this point in the history
Ensures that there is no unneeded space after opening parenthesis
while prompting a user for required setting.

Fixes coala#3164
  • Loading branch information
dracarys09 committed Dec 27, 2016
1 parent 23c023b commit 23be53b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coalib/settings/DocstringMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def from_docstring(cls, docstring):

def concat_doc_parts(old: str, new: str):
if new != '' and not old.endswith('\n'):
return old + ' ' + new
return (old + ' ' + new).strip()

return old + (new if new != '' else '\n')

Expand Down
20 changes: 20 additions & 0 deletions tests/settings/DocstringMetadataTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest

from coalib.settings.DocstringMetadata import DocstringMetadata
from collections import OrderedDict


class DocstringMetadataTest(unittest.TestCase):
Expand Down Expand Up @@ -54,6 +55,25 @@ def test_str(self):

self.assertEqual(str(uut), 'Description of something with params.')

def test_unneeded_docstring_space(self):
uut = DocstringMetadata.from_docstring(
"""
This is a description about some bear which does some amazing
things. This is a multiline description for this testcase.
:param language:
The programming language.
:param coalang_dir:
External directory for coalang file.
""")

expected_output = OrderedDict([('language', ('The programming '
'language.')),
('coalang_dir', ('External directory '
'for coalang file.'))])

self.assertEqual(uut.param_dict, expected_output)

def check_from_docstring_dataset(self,
docstring,
desc='',
Expand Down

0 comments on commit 23be53b

Please sign in to comment.