Skip to content

Commit 09832b8

Browse files
committed
Revert missing tests
1 parent c549a77 commit 09832b8

23 files changed

Lines changed: 1623 additions & 267 deletions

pygame_menu/_scrollarea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __init__(
252252
self._border_color = border_color
253253
self._border_width = border_width
254254
self._bg_surface = None
255-
self._decorator = Decorator(self)
255+
self._decorator = Decorator(self) # type: ignore
256256
self._scrollbar_positions = tuple(unique_scrolls) # Ensure unique
257257
self._translate = (0, 0)
258258
self._world = world

pygame_menu/examples/other/dynamic_widget_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self) -> None:
104104

105105
# Update the widgets based on selected value from selector get_value
106106
# returns selected item tuple and index, so [0][1] means the second object
107-
# from ('The first', 1) tuple
107+
# from ("The first", 1) tuple
108108
self._update_from_selection(int(self.selector_widget.get_value()[0][1]))
109109

110110
def animate_quit_button(

pygame_menu/themes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -709,24 +709,24 @@ def validate(self) -> Theme:
709709
self.widget_url_color = self._format_color_opacity(self.widget_url_color)
710710

711711
# List to tuple
712-
self.scrollarea_outer_margin = self._vec_to_tuple(
712+
self.scrollarea_outer_margin = self._vec_to_tuple( # type: ignore
713713
self.scrollarea_outer_margin, 2, NumberInstance
714714
)
715-
self.title_offset = self._vec_to_tuple(self.title_offset, 2, NumberInstance)
716-
self.widget_background_inflate = self._vec_to_tuple(
715+
self.title_offset = self._vec_to_tuple(self.title_offset, 2, NumberInstance) # type: ignore
716+
self.widget_background_inflate = self._vec_to_tuple( # type: ignore
717717
self.widget_background_inflate, 2, int
718718
)
719-
self.widget_border_inflate = self._vec_to_tuple(
719+
self.widget_border_inflate = self._vec_to_tuple( # type: ignore
720720
self.widget_border_inflate, 2, int
721721
)
722-
self.widget_box_arrow_margin = self._vec_to_tuple(
722+
self.widget_box_arrow_margin = self._vec_to_tuple( # type: ignore
723723
self.widget_box_arrow_margin, 3, int
724724
)
725-
self.widget_box_inflate = self._vec_to_tuple(self.widget_box_inflate, 2, int)
726-
self.widget_box_margin = self._vec_to_tuple(
725+
self.widget_box_inflate = self._vec_to_tuple(self.widget_box_inflate, 2, int) # type: ignore
726+
self.widget_box_margin = self._vec_to_tuple( # type: ignore
727727
self.widget_box_margin, 2, NumberInstance
728728
)
729-
self.widget_margin = self._vec_to_tuple(self.widget_margin, 2, NumberInstance)
729+
self.widget_margin = self._vec_to_tuple(self.widget_margin, 2, NumberInstance) # type: ignore
730730
if isinstance(self.widget_padding, VectorInstance):
731731
self.widget_padding = self._vec_to_tuple(self.widget_padding)
732732
assert 2 <= len(self.widget_padding) <= 4, (
@@ -739,7 +739,7 @@ def validate(self) -> Theme:
739739
assert p >= 0, "all padding elements must be equal or greater than zero"
740740
else:
741741
assert self.widget_padding >= 0, "padding cannot be a negative number"
742-
self.widget_offset = self._vec_to_tuple(self.widget_offset, 2, NumberInstance)
742+
self.widget_offset = self._vec_to_tuple(self.widget_offset, 2, NumberInstance) # type: ignore
743743

744744
# Check sizes
745745
assert self.border_width >= 0, "border width must be equal or greater than zero"

test/_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def mouse_click(
385385
evtype, {"button": button, "pos": (x, y), "rel": rel, "test": testmode}
386386
)
387387
if update_mouse:
388-
# print('set mouse position', (x, y))
389388
pygame.mouse.set_pos((x, y))
390389
if inlist:
391390
event_obj = [event_obj]

test/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@pytest.fixture(autouse=True)
1414
def disable_gc():
15+
"""Disable garbage collection."""
1516
gc.disable()
1617
yield
1718
gc.enable()

test/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_repr_class_id():
117117
"""Class ID repr flag returns Class<id> format."""
118118
obj = Base("id2")
119119
obj._class_id__repr__ = True
120-
assert repr(obj) == 'Base<"id2">'
120+
assert repr(obj) == "Base<\"id2\">"
121121

122122

123123
def test_repr_conflict_raises():
@@ -165,4 +165,4 @@ def test_verbose_type_error():
165165
def test_class_id_format():
166166
"""get_class_id returns Class<id> format."""
167167
obj = Base("id")
168-
assert obj.get_class_id() == 'Base<"id">'
168+
assert obj.get_class_id() == "Base<\"id\">"

test/test_baseimage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def test_modes(mode):
186186
def test_modes_invalid():
187187
"""Test invalid drawing mode."""
188188
with pytest.raises(AssertionError):
189+
# Attempt to create an invalid drawing mode
189190
pygame_menu.BaseImage(
190191
pygame_menu.baseimage.IMAGE_EXAMPLE_GRAY_LINES, drawing_mode=-1
191192
)
@@ -362,11 +363,8 @@ def test_transform():
362363

363364
# Image channels
364365
image.pick_channels(("r", "g", "b"))
365-
366366
assert image.get_at((10, 10)) == (56, 56, 56, 255)
367-
368367
image.set_at((10, 10), (0, 0, 0))
369-
# assert image.get_at((10, 10)) == (0, 0, 0, 255)
370368

371369

372370
@pytest.mark.parametrize(

test/test_controls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def toggle_button(menu):
3131
state = {"value": False}
3232

3333
def toggle():
34+
"""Toggle state."""
3435
state["value"] = not state["value"]
3536

3637
btn = menu.add.button("toggle", toggle)
@@ -150,6 +151,7 @@ def test_key_apply_affects_future_widgets(menu):
150151
state = {"value": False}
151152

152153
def toggle():
154+
"""Toggle state."""
153155
state["value"] = not state["value"]
154156

155157
btn = menu.add.button("x", toggle)
@@ -164,6 +166,7 @@ def test_custom_controller_apply(toggle_button):
164166
count = {"n": 0}
165167

166168
def custom_apply(event, _):
169+
"""Custom apply method overrides default behavior."""
167170
count["n"] += 1
168171
return event.key == pygame.K_a
169172

test/test_decorator.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,25 @@ def test_time_draw():
3131
for _ in range(10000):
3232
deco.add_pixel(1, 2, (0, 0, 0))
3333

34+
# (100) no cache, 0.214
35+
# (100) with cache, 0.646
36+
# (250) no cache, 0.467
37+
# (250) with cache, 0.594
38+
# (300) no cache, 0.581
39+
# (300) with cache, 0.606
40+
# (400) no cache, 0.82
41+
# (400) with cache, 0.638
42+
# (500) no cache, 1.087
43+
# (500) with cache, 0.601
44+
# (750) no cache, 1.484
45+
# (750) with cache, 0.664
46+
# (1.000) no cache, 2.228
47+
# (1.000) with cache, 0.615
48+
# (10.000) no cache, 20.430
49+
# (10.000) with cache, 0.599
50+
print("Total decorations", deco._total_decor(), "Cache", deco.cache)
3451
total_tests = 10
35-
total = 0
52+
total = 0 # Total time
3653
for i in range(total_tests):
3754
t = timeit.timeit(lambda: widg.draw(surface), number=1000)
3855
total += t
@@ -97,7 +114,6 @@ def test_copy():
97114
"""Test decorator copy."""
98115
widg = NoneWidget()
99116
deco = widg.get_decorator()
100-
101117
with pytest.raises(Exception):
102118
copy.copy(deco)
103119
with pytest.raises(Exception):
@@ -141,6 +157,7 @@ def test_enable_disable():
141157
test = [False]
142158

143159
def fun(surf, obj):
160+
"""Test callable decoration."""
144161
test[0] = True
145162
assert isinstance(surf, pygame.Surface)
146163
assert isinstance(obj, Button)
@@ -277,6 +294,7 @@ def test_general():
277294
test = [False]
278295

279296
def fun(_, __):
297+
"""Test callable decoration."""
280298
test[0] = True
281299

282300
deco.add_callable(fun)
@@ -287,6 +305,7 @@ def fun(_, __):
287305
test[0] = False
288306

289307
def fun_noargs():
308+
"""No args function."""
290309
test[0] = True
291310

292311
deco.add_callable(fun_noargs, pass_args=False)

test/test_examples.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ def test_example_multi_input():
5353
multi_input.update_menu_sound(("sound", None), True)
5454
multi_input.update_menu_sound(("sound", None), False)
5555

56+
# Test methods within submenus
5657
settings = multi_input.main_menu.get_submenus()[0]
5758
settings.get_widget("store").apply()
5859

60+
# Check range slider has event
5961
rslider = settings.get_widget("range_slider")
6062
assert rslider._onchange is not None
6163
assert rslider.get_value() == 50
@@ -238,7 +240,6 @@ def test_example_other_scrollbar():
238240
"""Test scrollbar example."""
239241
pygame.event.post(PygameEventUtils.keydown(pygame.K_v, inlist=False))
240242
pygame.event.post(PygameEventUtils.keydown(pygame.K_h, inlist=False))
241-
242243
scrollbar.main(test=True)
243244
scrollbar.h_changed(1)
244245
scrollbar.v_changed(1)

0 commit comments

Comments
 (0)