11"""Tests that layouts warn when explicit width/height conflicts with active size_hint."""
2+ import warnings
3+
24import pytest
35
46from arcade .gui import UIBoxLayout
@@ -19,14 +21,16 @@ def test_anchor_layout_warns_when_height_given_with_default_size_hint(window):
1921
2022def test_anchor_layout_no_warning_when_size_hint_none (window ):
2123 """UIAnchorLayout should not warn when size_hint=None is explicitly set."""
22- # No warning expected
23- UIAnchorLayout (width = 500 , height = 500 , size_hint = None )
24+ with warnings .catch_warnings ():
25+ warnings .simplefilter ("error" )
26+ UIAnchorLayout (width = 500 , height = 500 , size_hint = None )
2427
2528
2629def test_anchor_layout_no_warning_when_no_explicit_size (window ):
2730 """UIAnchorLayout should not warn when width/height are not explicitly given."""
28- # No warning expected
29- UIAnchorLayout (size_hint = (1 , 1 ))
31+ with warnings .catch_warnings ():
32+ warnings .simplefilter ("error" )
33+ UIAnchorLayout (size_hint = (1 , 1 ))
3034
3135
3236def test_anchor_layout_no_warning_when_size_hint_x_none (window ):
@@ -57,14 +61,16 @@ def test_box_layout_warns_when_height_given_with_default_size_hint(window):
5761
5862def test_box_layout_no_warning_when_size_hint_none (window ):
5963 """UIBoxLayout should not warn when size_hint=None is explicitly set."""
60- # No warning expected
61- UIBoxLayout (width = 200 , height = 200 , size_hint = None )
64+ with warnings .catch_warnings ():
65+ warnings .simplefilter ("error" )
66+ UIBoxLayout (width = 200 , height = 200 , size_hint = None )
6267
6368
6469def test_box_layout_no_warning_when_no_explicit_size (window ):
6570 """UIBoxLayout should not warn when width/height are not explicitly given."""
66- # No warning expected
67- UIBoxLayout (size_hint = (0 , 0 ))
71+ with warnings .catch_warnings ():
72+ warnings .simplefilter ("error" )
73+ UIBoxLayout (size_hint = (0 , 0 ))
6874
6975
7076def test_grid_layout_warns_when_width_given_with_default_size_hint (window ):
@@ -81,14 +87,16 @@ def test_grid_layout_warns_when_height_given_with_default_size_hint(window):
8187
8288def test_grid_layout_no_warning_when_size_hint_none (window ):
8389 """UIGridLayout should not warn when size_hint=None is explicitly set."""
84- # No warning expected
85- UIGridLayout (width = 200 , height = 200 , size_hint = None )
90+ with warnings .catch_warnings ():
91+ warnings .simplefilter ("error" )
92+ UIGridLayout (width = 200 , height = 200 , size_hint = None )
8693
8794
8895def test_grid_layout_no_warning_when_no_explicit_size (window ):
8996 """UIGridLayout should not warn when width/height are not explicitly given."""
90- # No warning expected
91- UIGridLayout (size_hint = (0 , 0 ))
97+ with warnings .catch_warnings ():
98+ warnings .simplefilter ("error" )
99+ UIGridLayout (size_hint = (0 , 0 ))
92100
93101
94102def test_warning_message_includes_class_name (window ):
0 commit comments