async def test_waiting_until_on_fails_when_not_turned_on(): toggle = Toggle(False) with pytest.raises(asyncio.TimeoutError): await asyncio.wait_for(toggle.wait_for(True), timeout=0.1) assert toggle.is_off()
async def test_turning_off(): toggle = Toggle(True) await toggle.turn_to(False) assert not toggle.is_on() assert toggle.is_off()
async def test_repr_when_named_and_on(): toggle = Toggle(True, name='xyz') assert toggle.name == 'xyz' assert repr(toggle) == "<Toggle: xyz: on>"
async def test_initialised_as_on(): toggle = Toggle(True) assert toggle.is_on() assert not toggle.is_off()
async def test_repr_when_named_and_off(): toggle = Toggle(False, name='xyz') assert toggle.name == 'xyz' assert repr(toggle) == "<Toggle: xyz: off>"