def test_factory(self): class MockImage(img.PngFactory): def __init__(self, screen): super().__init__('title_card', screen, path_type=img.PathType.COMMON) image = img.load(self.screen, factory=MockImage) self.assertIsInstance(image, MockImage)
def __init__(self, screen): super().__init__(screen) self._hidden_objects = { name: cls(self._surface) for name, cls in self._HIDDEN_OBJECTS.items() } self._state = {name: object() for name in self._STATE} self.player = img.load('player', self._surface, (state.RECT.h / 2, state.RECT.h / 2), (-0.5, -0.5)) self._scroll_speed: Optional[interactions.Speed] = None self._player_feet_rect = pygame.Rect( self.player.RECT.x, self.player.RECT.bottom - _PLAYER_FEET_HEIGHT, self.player.RECT.w, _PLAYER_FEET_HEIGHT)
def set_item(self, name): self._item = _Item(name, img.load( os.path.join('item', name), self._screen, (self.RECT.centerx, self.RECT.centery), (-0.5, -0.5)))
def __init__(self, screen): keypad = img.load(screen, factory=room.KeyPad) keypad.text = '9710' # opens the keypad so 'OK' will be centered keypad.text = 'OK' super().__init__(screen, color.GREY, keypad)
def test_shift(self): image = img.load('title_card', self.screen, shift=(1, 1), path_type=img.PathType.COMMON) self.assertFalse(image.collidepoint((0, 0)))
def test_position(self): image = img.load('title_card', self.screen, (-1, -1), path_type=img.PathType.COMMON) self.assertTrue(image.collidepoint((-1, -1)))
def test_collidepoint(self): image = img.load('title_card', self.screen, path_type=img.PathType.COMMON) self.assertTrue(image.collidepoint((0, 0))) self.assertFalse(image.collidepoint((-1, -1)))
def test_draw(self): image = img.load('title_card', self.screen, path_type=img.PathType.COMMON) image.draw() self.screen.blit.assert_called_once()
def test_load(self): img.load('title_card', self.screen, path_type=img.PathType.COMMON)