Skip to content
Snippets Groups Projects
Verified Commit 16b6a10f authored by Martin Kourim's avatar Martin Kourim :rocket:
Browse files

fix: Fix parsing with leading blank line

parent f1b3805e
No related branches found
No related tags found
No related merge requests found
Pipeline #90999863 passed
......@@ -77,7 +77,7 @@ class DocstringParser:
return key, value
# pylint: disable=too-many-locals
def lines_to_dict(self, lines, start=0, lineno_offset=0, stop=None):
def lines_to_dict(self, lines, start=0, lineno_offset=0, stop=None): # noqa: C901
"""Create dictionary out of docstring lines.
Includes column and line number info for each record.
......@@ -88,7 +88,7 @@ class DocstringParser:
lines = lines[start:]
docstring_dict = {}
indent = len(lines[0]) - len(lines[0].lstrip(" "))
indent = 0
is_multiline = False
prev_key = None
for num, line in enumerate(lines, 1):
......@@ -98,6 +98,9 @@ class DocstringParser:
curr_indent = len(line) - len(line.lstrip(" "))
if not indent:
indent = curr_indent
if curr_indent < indent:
break
......@@ -160,12 +163,17 @@ class DocstringParser:
lines_list = []
is_multiline = False
indent = len(lines[0]) - len(lines[0].lstrip(" "))
indent = 0
for num, line in enumerate(lines, 1):
line_stripped = line.strip()
if not line_stripped:
continue
curr_indent = len(line) - len(line.lstrip(" "))
if not indent:
indent = curr_indent
if curr_indent < indent:
break
......
......@@ -105,6 +105,7 @@ def test_wrong_steps_indent():
def test_multiline():
"""BAR
Polarion:
assignee: mkourim
initialEstimate: 1/4h
title: >
......@@ -115,6 +116,7 @@ def test_multiline():
2. >
Log something
expectedResults:
1.
2. >
<NoMethodError>: <undefined method `service_resources" for
......
......@@ -144,19 +144,19 @@ EXPECTED = {
lineno=107,
column=4,
value={
"assignee": ValueRecord(lineno=1, column=8, value="mkourim"),
"initialEstimate": ValueRecord(lineno=2, column=8, value="1/4h"),
"assignee": ValueRecord(lineno=2, column=8, value="mkourim"),
"initialEstimate": ValueRecord(lineno=3, column=8, value="1/4h"),
"title": ValueRecord(
lineno=3, column=8, value="Test multiple tenant quotas simultaneously"
lineno=4, column=8, value="Test multiple tenant quotas simultaneously"
),
"testSteps": [
ValueRecord(lineno=7, column=12, value="1."),
ValueRecord(lineno=8, column=12, value="2. Log something"),
ValueRecord(lineno=8, column=12, value="1."),
ValueRecord(lineno=9, column=12, value="2. Log something"),
],
"expectedResults": [
ValueRecord(lineno=11, column=12, value="1."),
ValueRecord(lineno=13, column=12, value="1."),
ValueRecord(
lineno=12,
lineno=14,
column=12,
value='2. <NoMethodError>: <undefined method `service_resources" for '
"nil:NilClass> [----] E, [2018-01-06T11:11:20.074019 #13027:e0ffc4] "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment