File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ def lines_matching(self, *regexes: str) -> set[TLineNo]:
115
115
matches = set ()
116
116
for i , ltext in enumerate (self .lines , start = 1 ):
117
117
if regex_c .search (ltext ):
118
- matches .add (i )
118
+ matches .add (self . _multiline . get ( i , i ) )
119
119
return matches
120
120
121
121
def _raw_parse (self ) -> None :
Original file line number Diff line number Diff line change @@ -425,6 +425,24 @@ def f():
425
425
)
426
426
assert parser .statements == {1 ,7 }
427
427
428
+ def test_multiline_if_no_branch (self ) -> None :
429
+ # From https://github.com/nedbat/coveragepy/issues/754
430
+ parser = self .parse_text ("""\
431
+ if (this_is_a_verylong_boolean_expression == True # pragma: no branch
432
+ and another_long_expression and here_another_expression):
433
+ do_something()
434
+ """ ,
435
+ )
436
+ parser2 = self .parse_text ("""\
437
+ if this_is_a_verylong_boolean_expression == True and another_long_expression \\
438
+ and here_another_expression: # pragma: no branch
439
+ do_something()
440
+ """ ,
441
+ )
442
+ assert parser .statements == parser2 .statements == {1 , 3 }
443
+ pragma_re = ".*pragma: no branch.*"
444
+ assert parser .lines_matching (pragma_re ) == parser2 .lines_matching (pragma_re )
445
+
428
446
def test_excluding_function (self ) -> None :
429
447
parser = self .parse_text ("""\
430
448
def fn(foo): # nocover
You can’t perform that action at this time.
0 commit comments