Skip to content

Commit

Permalink
Fix layered UI Group test
Browse files Browse the repository at this point in the history
  • Loading branch information
MyreMylar committed Aug 3, 2022
1 parent c98deb1 commit b23cb22
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions tests/test_core/test_layered_gui_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,53 @@ def update(self, time_delta: float):
pass


class MyDodgySprite1(GUISprite):
class MyDodgySprite1:
def __init__(self, *groups):
super().__init__(*groups)
self.blendmode = 0

self.__g = {}
if groups:
self.add(*groups)

def add(self, *groups):
has = self.__g.__contains__
for group in groups:
if hasattr(group, '_spritegroup'):
if not has(group):
group.add_internal(self)
else:
self.add(*group)

def update(self, time_delta: float):
pass


class MyDodgySprite2(GUISprite):
class MyDodgySprite2:
def __init__(self, *groups):
super().__init__(*groups)
self.visible = 1

self.__g = {}
if groups:
self.add(*groups)

def add(self, *groups):
has = self.__g.__contains__
for group in groups:
if hasattr(group, '_spritegroup'):
if not has(group):
group.add_internal(self)
else:
self.add(*group)

def update(self, time_delta: float):
pass


class MyDodgySprite3(pygame.sprite.Sprite):
def __init__(self, *groups):
super().__init__(*groups)
self.blendmode = 0
self.visible = 1
super().__init__(*groups)


class TestUIElement:
Expand Down Expand Up @@ -67,7 +91,7 @@ def test_add_dodgy_sprites(self, _init_pygame, default_ui_manager):
with pytest.raises(AttributeError):
MyDodgySprite2(group)

with pytest.raises(AttributeError):
with pytest.raises(TypeError):
MyDodgySprite3(group)

def test_sprite_set_layer_before_add(self, _init_pygame, default_ui_manager):
Expand Down

0 comments on commit b23cb22

Please sign in to comment.