def test_operators(): time1 = seconds(3) time2 = seconds(5) assert not time1 == time2 assert time1 != time2 assert time1 < time2 assert not time1 > time2 assert time1 <= time2 assert not time1 >= time2 assert (-time1).as_seconds() == -3 assert (time1 + time2).as_seconds() == 8 time1 += time1 assert time1.as_seconds() == 6 assert (time2 - time2).as_seconds() == 0 time1 -= time1 / 2 assert time1.as_seconds() == 3 assert (time1 * 3).as_seconds() == 9 assert (3 * time1).as_seconds() == 9 assert (time1 / 3).as_seconds() == 1
def test_seconds(): time = seconds(3) assert isinstance(time, Time) assert time.as_seconds() == 3 assert time.as_milliseconds() == 3000 assert time.as_microseconds() == 3000000
def test_playing_offset(): sound = Sound() assert isinstance(sound.playing_offset, Time) assert sound.playing_offset.as_seconds() == 0 sound_buffer = SoundBuffer() resources = pathlib.Path(__file__).parent.parent.absolute() / 'resources' sound_buffer.load_from_file(str(resources / 'canary.wav')) sound.buffer = sound_buffer sound.loop = True sound.play() sound.playing_offset = seconds(0.5) assert type(sound.playing_offset) is Time
def test_repr(): time = seconds(3) assert str(time) == '<pysfml11.Time seconds=3>'
def test_elapsed_time(): clock = Clock() sleep(seconds(1)) assert clock.elapsed_time.as_seconds() >= 1