This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,25 +1,17 @@
#################################### IMPORTS ###################################
import types
import typing
import unittest
import pygame
from pygame import sprite
################################# MODULE LEVEL #################################
class SpriteModuleTest(unittest.TestCase):
def test_deprecation__sprite_submodule(self):
# Test that using the old cython sprite module raises
# a deprecation warning.
with self.assertWarns(DeprecationWarning):
import pygame._sprite
pygame.init()
test_group = pygame.sprite.Group()
pass
######################### SPRITECOLLIDE FUNCTIONS TEST #########################
@@ -527,7 +519,7 @@ class AbstractGroupTypeTest(unittest.TestCase):
self.bg = pygame.Surface((20, 20))
self.scr = pygame.Surface((20, 20))
self.scr.fill(pygame.Color("gray"))
self.scr.fill(pygame.Color("grey"))
def test_has(self):
"See if AbstractGroup.has() works as expected."
@@ -661,16 +653,6 @@ class AbstractGroupTypeTest(unittest.TestCase):
self.assertEqual(test_sprite.sink, [1, 2, 3])
self.assertEqual(test_sprite.sink_kwargs, {"foo": 4, "bar": 5})
def test_type_subscript(self):
try:
group_generic_alias = sprite.Group[sprite.Sprite]
except TypeError as e:
self.fail(e)
self.assertIsInstance(group_generic_alias, types.GenericAlias)
self.assertIs(typing.get_origin(group_generic_alias), sprite.Group)
self.assertEqual(typing.get_args(group_generic_alias), (sprite.Sprite,))
################################################################################
@@ -1129,7 +1111,7 @@ class LayeredDirtyTypeTest__DirtySprite(LayeredGroupBase, unittest.TestCase):
# use_source_rect - allows non-dirty sprites to be tested
# with (True) and without (False) a source_rect
#
# This test was written to reproduce the behavior seen in pygame-ce issue # 605.
# This test was written to reproduce the behavior seen in issue #898.
# A non-dirty sprite (using source_rect) was being redrawn incorrectly
# after a dirty sprite intersected with it.
#
@@ -1225,7 +1207,7 @@ class LayeredDirtyTypeTest__DirtySprite(LayeredGroupBase, unittest.TestCase):
"""Ensure non-dirty sprites using source_rects are correctly redrawn
when dirty sprites intersect with them.
Related to pygame-ce issue #605.
Related to issue #898.
"""
self._nondirty_intersections_redrawn(True)
@@ -1261,6 +1243,7 @@ class SpriteBase:
self.assertFalse(g in self.sprite.groups())
def test_update(self):
# What does this and the next test actually test?
class test_sprite(pygame.sprite.Sprite):
sink = []
@@ -1351,6 +1334,7 @@ class SpriteTypeTest(SpriteBase, unittest.TestCase):
sprite.Group,
sprite.LayeredUpdates,
sprite.RenderUpdates,
sprite.OrderedUpdates,
]
@@ -1361,20 +1345,42 @@ class DirtySpriteTypeTest(SpriteBase, unittest.TestCase):
sprite.Group,
sprite.LayeredUpdates,
sprite.RenderUpdates,
sprite.OrderedUpdates,
sprite.LayeredDirty,
]
class WeakSpriteTypeTest(SpriteTypeTest):
Sprite = sprite.WeakSprite
def test_weak_group_ref(self):
"""
We create a list of groups, add them to the sprite.
When we then delete the groups, the sprite should be "dead"
"""
import gc
groups = [Group() for Group in self.Groups]
self.sprite.add(groups)
del groups
gc.collect()
self.assertFalse(self.sprite.alive())
class DirtyWeakSpriteTypeTest(DirtySpriteTypeTest, WeakSpriteTypeTest):
Sprite = sprite.WeakDirtySprite
############################## BUG TESTS #######################################
class SingleGroupBugsTest(unittest.TestCase):
def test_memoryleak_bug(self):
# For memory leak bug posted to mailing list by Tobias Steinrücken on 16/11/10.
# For memoryleak bug posted to mailing list by Tobias Steinrücken on 16/11/10.
# Fixed in revision 2953.
import gc
import weakref
import gc
class MySprite(sprite.Sprite):
def __init__(self, *args, **kwargs):