def test_framerate_range(camera, previewing): save_framerate = camera.framerate try: tol = Fraction(1, 256) camera.framerate_range = (Fraction(1, 6), 1) assert camera.framerate == 0 assert isclose(camera.framerate_range.low, Fraction(1, 6), rel_tol=tol) assert isclose(camera.framerate_range.high, 1, rel_tol=tol) camera.framerate_range = (Fraction(50, 1000), Fraction(166, 1000)) assert camera.framerate == 0 assert isclose(camera.framerate_range.low, Fraction(50, 1000), rel_tol=tol) assert isclose(camera.framerate_range.high, Fraction(166, 1000), rel_tol=tol) camera.framerate_range = (1, 5) assert camera.framerate == 0 assert camera.framerate_range == (1, 5) camera.framerate_range = (1, 30.0) assert camera.framerate == 0 assert camera.framerate_range == (1, 30) with pytest.raises(picamera.PiCameraError): camera.framerate_delta = 1 with pytest.raises(picamera.PiCameraError): camera.framerate_range = (1, 200) with pytest.raises(picamera.PiCameraError): camera.framerate_range = (0, 30) with pytest.raises(picamera.PiCameraError): camera.framerate_range = (2, 1) finally: camera.framerate = save_framerate
def test_framerate_delta(camera, previewing): for num in range(-10, 11): camera.framerate_delta = num / 10 assert isclose(camera.framerate_delta, Fraction(num, 10), rel_tol=Fraction(1, 256))