Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

# Simple sample to demonstrate the statement coverage capabilities of Coverage.py. 

import sys 

 

# Function with multiple branches. 

def statementCoverageDemo(number): 

6 ↛ 7line 6 didn't jump to line 7, because the condition on line 6 was never true if number < 0: 

print('Value is negative.') 

8 ↛ 9line 8 didn't jump to line 9, because the condition on line 8 was never true elif number == 0: 

print('Value is 0.') 

else: 

print('Value is positive.') 

 

 

# Module tests 

if __name__ == '__main__': # pragma: no cover 

n = float(sys.argv[1]) 

statementCoverageDemo(n)