| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import pygame
- import pytest
- from pytest import fixture, mark
- from jogai import videogame as vg
- @mark.xfail
- @mark.parametrize(
- ('key, down'),
- [('a', False), (-1, True), ('pataca', True), ('', True), (None, True)],
- )
- def test_simulate_key_press(key, down):
- vg.init()
- vg.simulate_key_press(key, down)
- vg.quit()
- def test_listen_quit_event():
- quit_event = pygame.event.Event(
- pygame.QUIT,
- mod=pygame.locals.KMOD_NONE,
- )
- vg.init()
- pygame.event.post(quit_event)
- vg.listen_events()
- def test_get_color_with_wrong_types():
- with pytest.raises(TypeError):
- vg.get_color('foo', 'bar')
- def test_get_color_with_out_of_range_values():
- with pytest.raises(ValueError):
- vg.get_color(-3, 100000)
- @mark.parametrize('wait', [-1, 0, 1, 'foo', None])
- def test_wait_and_quit(wait):
- vg.quit(wait)
- def test_prepare_02_yaml():
- vg.init()
- vg.prepare('02.yaml')
- vg.quit()
- def test_load_yaml_with_no_characters():
- vg.init()
- vg.prepare('no_characters.yaml')
- vg.quit()
- def test_add_character_with_wrong_type():
- with pytest.raises(TypeError):
- vg.add_character('foo')
- def test_update(prepare_videogame):
- vg.update()
|