test_scene.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # jogai - Python Game Library
  2. #
  3. # This library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Library General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2 of the License, or (at your option) any later version.
  7. #
  8. # This library is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # Library General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU Library General Public
  14. # License along with this library; if not, write to the Free
  15. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. #
  17. # Ramón Palleiro Rodríguez
  18. # Zero! Factorial Studio
  19. # info@zero.gal
  20. import os
  21. import pytest
  22. from jogai import *
  23. def test_height_is_a_non_negative_integer(prepare_videogame):
  24. assert vgscene.height > -1
  25. def test_width_is_a_non_negative_integer(prepare_videogame):
  26. assert vgscene.width > -1
  27. def test_x_coordinate_is_an_integer(prepare_videogame):
  28. assert isinstance(vgscene.x, int)
  29. def test_change_background_color_with_components_out_of_range():
  30. with pytest.raises(ValueError):
  31. sc = Scene()
  32. sc.change_background((-1, -1, 300))
  33. def test_change_background_color_with_less_components():
  34. with pytest.raises(ValueError):
  35. sc = Scene()
  36. sc.change_background((0, 0))
  37. def test_change_background_color_wrong_type():
  38. with pytest.raises(ValueError):
  39. sc = Scene()
  40. sc.change_background('a')
  41. def test_create_scene_with_wrong_type():
  42. with pytest.raises(TypeError):
  43. sc = Scene(-1)
  44. def test_set_position_with_wrong_type(prepare_videogame):
  45. with pytest.raises(TypeError):
  46. vgscene.set_position('foo')