| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # jogai - Python Game Library
- #
- # This library is free software; you can redistribute it and/or
- # modify it under the terms of the GNU Library General Public
- # License as published by the Free Software Foundation; either
- # version 2 of the License, or (at your option) any later version.
- #
- # This library is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # Library General Public License for more details.
- #
- # You should have received a copy of the GNU Library General Public
- # License along with this library; if not, write to the Free
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- #
- # Ramón Palleiro Rodríguez
- # Zero! Factorial Studio
- # info@zero.gal
- import pygame
- import pytest
- from pytest import fixture, mark
- from jogai import videogame as vg
- def test_load_empty_scene():
- vg._load_scene({})
- @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_add_group_with_wrong_type():
- with pytest.raises(TypeError):
- vg.add_group('foo')
- 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()
|