Skip to content

Commit 4a39fd3

Browse files
youtuxolegpidsadnyi
authored andcommitted
Parse multilines according to the gherkin specification (delimited by """ quotes)
1 parent 34bc885 commit 4a39fd3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pytest_bdd/feature.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,17 @@ def add_line(self, line):
545545
@property
546546
def name(self):
547547
"""Get step name."""
548-
lines = [self._name] + ([textwrap.dedent("\n".join(self.lines))] if self.lines else [])
548+
multilines_content = textwrap.dedent("\n".join(self.lines)) if self.lines else ""
549+
550+
# Remove the multiline quotes, if present.
551+
multilines_content = re.sub(
552+
pattern=r'^"""\n(?P<content>.*)\n"""$',
553+
repl=r'\g<content>',
554+
string=multilines_content,
555+
flags=re.DOTALL, # Needed to make the "." match also new liness
556+
)
557+
558+
lines = [self._name] + [multilines_content]
549559
return "\n".join(lines).strip()
550560

551561
@name.setter

0 commit comments

Comments
 (0)