Complete the code to write a simple test function using PyTest.
def test_addition(): assert 1 + 1 == [1]
The test checks if 1 + 1 equals 2, which is true, so the test will pass.
Complete the code to use a PyTest fixture for setup.
import pytest @pytest.fixture def sample_data(): return [1, 2, 3] def test_sum([1]): assert sum([1]) == 6
The test function must accept the fixture name sample_data as a parameter to use it.
Fix the error in the PyTest test function to correctly check for an exception.
import pytest def test_zero_division(): with pytest.raises([1]): 1 / 0
The code raises a ZeroDivisionError when dividing by zero, so the test must expect that exception.
Fill both blanks to create a parameterized test that checks multiple inputs.
import pytest @pytest.mark.parametrize("input,expected") def test_multiply([1], [2]): assert input * 2 == expected
The test function parameters must match the names in the parametrize decorator: input and expected.
Fill all three blanks to create a test that skips when a condition is met.
import pytest @pytest.mark.skipif([1], reason=[2]) def test_feature(): assert [3] == 10
The test is skipped if the condition is True. The reason explains why. The assertion checks if 5 + 5 equals 10.