@@ -292,6 +292,7 @@ class Scenario:
292
292
class Step :
293
293
type : str
294
294
_name : str
295
+ _full_name : str | None
295
296
line_number : int
296
297
indent : int
297
298
keyword : str
@@ -311,32 +312,37 @@ def __init__(self, name: str, type: str, indent: int, line_number: int, keyword:
311
312
self .scenario = None
312
313
self .background = None
313
314
self .lines = []
315
+ self ._full_name = None
314
316
315
317
def add_line (self , line : str ) -> None :
316
318
"""Add line to the multiple step.
317
319
318
320
:param str line: Line of text - the continuation of the step name.
319
321
"""
320
322
self .lines .append (line )
323
+ self ._full_name = None
321
324
322
325
@property
323
326
def name (self ) -> str :
324
- multilines_content = textwrap .dedent ("\n " .join (self .lines )) if self .lines else ""
325
-
326
- # Remove the multiline quotes, if present.
327
- multilines_content = re .sub (
328
- pattern = r'^"""\n(?P<content>.*)\n"""$' ,
329
- repl = r"\g<content>" ,
330
- string = multilines_content ,
331
- flags = re .DOTALL , # Needed to make the "." match also new lines
332
- )
327
+ if self ._full_name is None :
328
+ multilines_content = textwrap .dedent ("\n " .join (self .lines )) if self .lines else ""
329
+
330
+ # Remove the multiline quotes, if present.
331
+ multilines_content = re .sub (
332
+ pattern = r'^"""\n(?P<content>.*)\n"""$' ,
333
+ repl = r"\g<content>" ,
334
+ string = multilines_content ,
335
+ flags = re .DOTALL , # Needed to make the "." match also new lines
336
+ )
333
337
334
- lines = [self ._name ] + [multilines_content ]
335
- return "\n " .join (lines ).strip ()
338
+ lines = [self ._name ] + [multilines_content ]
339
+ self ._full_name = "\n " .join (lines ).strip ()
340
+ return self ._full_name
336
341
337
342
@name .setter
338
343
def name (self , value : str ) -> None :
339
344
self ._name = value
345
+ self ._full_name = None
340
346
341
347
def __str__ (self ) -> str :
342
348
"""Full step name including the type."""
0 commit comments