def test_doctest() -> None: """Test the given doctest in the Spinner class docstring.""" spinner = Spinner(8) spinner.spin(4) assert spinner.position == 4 spinner.spin(2) assert spinner.position == 6 spinner.spin(2) assert spinner.position == 0 spinner.spin(8) assert spinner.position == 0 spinner.spin(100) assert spinner.position == 4 spinner.spin_randomly() assert spinner.position == 2 if __name__ == '__main__': import pytest pytest.main(['prep2_sample_test.py'])
def test_new_spinner_position(slots: int) -> None: """Test that the position of a new spinner is always 0.""" spinner = Spinner(slots) assert spinner.position == 0 spinner.spin(slots) assert spinner.position == 0 spinner.spin(slots - 1) assert spinner.position == slots - 1
def test_buggy_consecutive_spins() -> None: """Test consecutive spins of your Spinner class. This test case has a bug in it.""" # TODO: There is a bug in this test case -- find it and fix it. # In its original state, this test case should NOT pass if # your Spinner is implemented correctly! # Do NOT change or remove any of the lines labelled with # "Do not change this line". s = Spinner(6) # Do not change this line s.spin(2) # Do not change this line expected_value1 = 2 assert s.position == expected_value1 # Do not change this line s.spin(2) # Do not change this line expected_value2 = 4 assert s.position == expected_value2 # Do not change this line
def test_doctest() -> None: """Test the given doctest in the Spinner class docstring.""" spinner = Spinner(8) spinner.spin(1000000000012) assert spinner.position == 4 spinner.spin(2) assert spinner.position == 6 spinner.spin(2) assert spinner.position == 0 spinner.spin(0) assert spinner.position == 0