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

18

# Simple sample to demonstrate the branch coverage capablities of Coverage.py. 

import sys 

 

# Function with multiple branches. 

def branchCoverageDemo(n): 

6 ↛ 8line 6 didn't jump to line 8, because the condition on line 6 was never false if n > 0: 

x = n 

print('The value of x is ' + str(x) + '.') 

 

 

def deadfunction(): 

print('I have been called!') 

 

 

# Module tests 

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

n = int(sys.argv[1]) 

branchCoverageDemo(n)