Complete the code to assert the function returns True for positive input.
def is_positive(num): return num > 0 def test_positive(): assert is_positive([1]) == True
The function returns True only if the input is greater than zero. Using 5 tests the positive branch.
Complete the test to check the function returns False for zero input.
def is_positive(num): return num > 0 def test_zero(): assert is_positive([1]) == False
The function returns False when the input is zero because zero is not greater than zero.
Fix the error in the test to cover the negative branch correctly.
def is_positive(num): return num > 0 def test_negative(): assert is_positive([1]) == False
Negative numbers like -2 cause the function to return False, covering the negative branch.
Fill both blanks to complete a test that covers both branches using pytest parametrize.
import pytest @pytest.mark.parametrize('input, expected', [ ([1], True), ([2], False) ]) def test_is_positive(input, expected): assert is_positive(input) == expected
10 is positive and should return True; -5 is negative and should return False, covering both branches.
Fill all three blanks to create a test function that covers positive, zero, and negative inputs with correct assertions.
import pytest @pytest.mark.parametrize('num, expected', [ ([1], True), ([2], False), ([3], False) ]) def test_branch_coverage(num, expected): assert is_positive(num) == expected
5 is positive (True), 0 is zero (False), and -1 is negative (False), covering all branches.