test_scene.py 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import os
  2. import pytest
  3. from jogai import *
  4. def test_height_is_a_non_negative_integer(prepare_videogame):
  5. assert vgscene.height > -1
  6. def test_width_is_a_non_negative_integer(prepare_videogame):
  7. assert vgscene.width > -1
  8. def test_x_coordinate_is_an_integer(prepare_videogame):
  9. assert isinstance(vgscene.x, int)
  10. def test_change_background_color_with_components_out_of_range():
  11. with pytest.raises(ValueError):
  12. sc = Scene()
  13. sc.change_background((-1, -1, 300))
  14. def test_change_background_color_with_less_components():
  15. with pytest.raises(ValueError):
  16. sc = Scene()
  17. sc.change_background((0, 0))
  18. def test_change_background_color_wrong_type():
  19. with pytest.raises(ValueError):
  20. sc = Scene()
  21. sc.change_background('a')
  22. def test_create_scene_with_wrong_type():
  23. with pytest.raises(TypeError):
  24. sc = Scene(-1)
  25. def test_set_position_with_wrong_type(prepare_videogame):
  26. with pytest.raises(TypeError):
  27. vgscene.set_position('foo')