@@ -80,20 +80,32 @@ def test_immutability() -> None:
80
80
pane_id = "pane123" , width = 80 , height = 24 , captured_content = ["Line1" ]
81
81
)
82
82
83
- # Attempting to modify a field should raise AttributeError with precise error message
84
- with pytest .raises (AttributeError , match = r"PaneSnapshot is immutable: cannot modify field 'width'" ):
83
+ # Attempting to modify a field should raise AttributeError
84
+ # with precise error message
85
+ with pytest .raises (
86
+ AttributeError , match = r"PaneSnapshot is immutable: cannot modify field 'width'"
87
+ ):
85
88
snapshot .width = 200 # type: ignore
86
89
87
- # Attempting to add a new field should raise AttributeError with precise error message
88
- with pytest .raises (AttributeError , match = r"PaneSnapshot is immutable: cannot modify field 'new_field'" ):
90
+ # Attempting to add a new field should raise AttributeError
91
+ # with precise error message
92
+ with pytest .raises (
93
+ AttributeError ,
94
+ match = r"PaneSnapshot is immutable: cannot modify field 'new_field'" ,
95
+ ):
89
96
snapshot .new_field = "value" # type: ignore
90
97
91
- # Attempting to delete a field should raise AttributeError with precise error message
92
- with pytest .raises (AttributeError , match = r"PaneSnapshot is immutable: cannot delete field 'width'" ):
98
+ # Attempting to delete a field should raise AttributeError
99
+ # with precise error message
100
+ with pytest .raises (
101
+ AttributeError , match = r"PaneSnapshot is immutable: cannot delete field 'width'"
102
+ ):
93
103
del snapshot .width
94
104
95
105
# Calling a method that tries to modify state should fail
96
- with pytest .raises (NotImplementedError , match = r"Snapshot is immutable. resize\(\) not allowed." ):
106
+ with pytest .raises (
107
+ NotImplementedError , match = r"Snapshot is immutable. resize\(\) not allowed."
108
+ ):
97
109
snapshot .resize (200 , 50 )
98
110
99
111
@@ -188,7 +200,7 @@ def test_bidirectional_references() -> None:
188
200
189
201
class DimensionTestCase (t .NamedTuple ):
190
202
"""Test fixture for validating dimensions in PaneSnapshot.
191
-
203
+
192
204
Note: This implementation intentionally allows any dimension values, including
193
205
negative or extremely large values. In a real-world application, you might want
194
206
to add validation to the class constructor if certain dimension ranges are required.
@@ -287,7 +299,7 @@ def test_frozen_flag(
287
299
error_match : str | None ,
288
300
) -> None :
289
301
"""Test behavior when attempting to manipulate the _frozen flag.
290
-
302
+
291
303
Note: We discovered that setting _frozen=False actually allows mutation,
292
304
which could be a potential security issue if users know about this behavior.
293
305
In a more secure implementation, the _frozen attribute might need additional
0 commit comments