Skip to content

Commit

Permalink
Fix tests for screen
Browse files Browse the repository at this point in the history
  • Loading branch information
lordmauve committed Nov 24, 2021
1 parent f87f160 commit 8eddda6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
15 changes: 9 additions & 6 deletions test/test_rect_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@
TEST_DISP_W, TEST_DISP_H = (500, 500)


pygame.init()
pygame.display.set_mode((TEST_DISP_W, TEST_DISP_H))


class RectActorTestSingularNoIp(unittest.TestCase):
@classmethod
def setUpClass(self):
def setUpClass(cls):
set_root(__file__)
pygame.init()
pygame.display.set_mode((TEST_DISP_W, TEST_DISP_H))

@classmethod
def tearDownClass(cls):
pygame.display.quit()

def setUp(self):
# the Alien should be 66 x 92 px
Expand Down Expand Up @@ -88,5 +90,6 @@ def testCollideRectTrueOverlapping(self):
def testCollideRectFalseSeparate(self):
self.assertFalse(self.separate_rect.colliderect(self.actor))


if __name__=="__main__":
unittest.main()
unittest.main()
11 changes: 10 additions & 1 deletion test/test_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from pgzero.screen import Screen
from pgzero.loaders import set_root, images
from pgzero.rect import Rect, ZRect


class ScreenTest(unittest.TestCase):
Expand All @@ -25,7 +26,8 @@ def tearDownClass(cls):
pygame.display.quit()

def setUp(self):
self.screen = Screen(self.surf)
self.screen = Screen()
self.screen._set_surface(self.surf)
self.screen.clear()

def assertImagesAlmostEqual(self, computed, expected):
Expand Down Expand Up @@ -199,6 +201,13 @@ def test_wrapped_gradient_text(self):
images.expected_wrapped_gradient_text
)

def test_bounds(self):
"""We can get a bounding rect for the screen."""
self.assertEqual(
self.screen.bounds(),
ZRect(0, 0, 200, 100)
)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8eddda6

Please sign in to comment.