@@ -19,12 +19,12 @@ def test_single_timezone_placed_before_event():
1919 event .start = datetime (2026 , 3 , 19 , 12 , 30 , tzinfo = ZoneInfo ("Europe/London" ))
2020 event .add ("SUMMARY" , "Test Event" )
2121 calendar .add_component (event )
22-
22+
2323 calendar .add_missing_timezones ()
24-
24+
2525 components = [comp .name for comp in calendar .subcomponents ]
2626 assert components == ["VTIMEZONE" , "VEVENT" ]
27-
27+
2828 # Verify the timezone is correct
2929 assert calendar .timezones [0 ].tz_name == "Europe/London"
3030
@@ -46,13 +46,13 @@ def test_multiple_timezones_placed_before_events():
4646 event2 .start = datetime (2026 , 3 , 19 , 15 , 30 , tzinfo = ZoneInfo ("America/New_York" ))
4747 event2 .add ("SUMMARY" , "New York Event" )
4848 calendar .add_component (event2 )
49-
49+
5050 calendar .add_missing_timezones ()
51-
51+
5252 components = [comp .name for comp in calendar .subcomponents ]
5353 assert components [:2 ] == ["VTIMEZONE" , "VTIMEZONE" ]
5454 assert components [2 :] == ["VEVENT" , "VEVENT" ]
55-
55+
5656 # Verify both timezones are present
5757 timezone_names = {tz .tz_name for tz in calendar .timezones }
5858 assert timezone_names == {"Europe/London" , "America/New_York" }
@@ -79,13 +79,13 @@ def test_existing_timezone_preserved_new_ones_added_correctly():
7979 event2 .start = datetime (2026 , 3 , 19 , 15 , 30 , tzinfo = ZoneInfo ("America/New_York" ))
8080 event2 .add ("SUMMARY" , "New York Event" )
8181 calendar .add_component (event2 )
82-
82+
8383 calendar .add_missing_timezones ()
84-
84+
8585 components = [comp .name for comp in calendar .subcomponents ]
8686 assert components [:2 ] == ["VTIMEZONE" , "VTIMEZONE" ]
8787 assert components [2 :] == ["VEVENT" , "VEVENT" ]
88-
88+
8989 # Verify both timezones are present (existing + new)
9090 timezone_names = {tz .tz_name for tz in calendar .timezones }
9191 assert timezone_names == {"Europe/Berlin" , "America/New_York" }
@@ -102,11 +102,11 @@ def test_no_missing_timezones_no_changes():
102102 event .start = datetime (2026 , 3 , 19 , 12 , 30 ) # No timezone
103103 event .add ("SUMMARY" , "No Timezone Event" )
104104 calendar .add_component (event )
105-
105+
106106 original_components = [comp .name for comp in calendar .subcomponents ]
107107 calendar .add_missing_timezones ()
108108 new_components = [comp .name for comp in calendar .subcomponents ]
109-
109+
110110 assert original_components == new_components == ["VEVENT" ]
111111
112112
@@ -115,9 +115,9 @@ def test_empty_calendar_add_missing_timezones():
115115 calendar = Calendar ()
116116 calendar .add ("VERSION" , "2.0" )
117117 calendar .add ("PRODID" , "test calendar" )
118-
118+
119119 calendar .add_missing_timezones ()
120-
120+
121121 components = [comp .name for comp in calendar .subcomponents ]
122122 assert components == []
123123
@@ -133,22 +133,22 @@ def test_timezone_placement_in_serialized_output():
133133 event .start = datetime (2026 , 3 , 19 , 12 , 30 , tzinfo = ZoneInfo ("Europe/London" ))
134134 event .add ("SUMMARY" , "Test Event" )
135135 calendar .add_component (event )
136-
136+
137137 calendar .add_missing_timezones ()
138-
138+
139139 # Check serialized output
140140 ical_content = calendar .to_ical ().decode ()
141- lines = ical_content .split (' \n ' )
142-
141+ lines = ical_content .split (" \n " )
142+
143143 vtimezone_line = None
144144 vevent_line = None
145-
145+
146146 for i , line in enumerate (lines ):
147147 if line .strip () == "BEGIN:VTIMEZONE" :
148148 vtimezone_line = i
149149 elif line .strip () == "BEGIN:VEVENT" :
150150 vevent_line = i
151-
151+
152152 assert vtimezone_line is not None
153153 assert vevent_line is not None
154154 assert vtimezone_line < vevent_line
@@ -175,7 +175,7 @@ def test_forward_reference_compatibility():
175175END:STANDARD
176176END:VTIMEZONE
177177END:VCALENDAR"""
178-
178+
179179 # This should still parse correctly due to existing forward reference handling
180180 calendar = Calendar .from_ical (ical_content )
181181 assert len (calendar .events ) == 1
@@ -187,16 +187,16 @@ def test_timezone_placement_without_pytz():
187187 """Test timezone placement. Works even if pytz is not available."""
188188 import sys
189189 import types
190-
190+
191191 # Temporarily mock pytz to simulate nopytz environment
192- original_pytz = sys .modules .get (' pytz' )
193-
192+ original_pytz = sys .modules .get (" pytz" )
193+
194194 class MockPytz :
195195 def __getattr__ (self , name ):
196196 raise ImportError ("No module named 'pytz'" )
197-
198- sys .modules [' pytz' ] = MockPytz ()
199-
197+
198+ sys .modules [" pytz" ] = MockPytz ()
199+
200200 try :
201201 calendar = Calendar ()
202202 calendar .add ("VERSION" , "2.0" )
@@ -207,17 +207,17 @@ def __getattr__(self, name):
207207 event .start = datetime (2026 , 3 , 19 , 12 , 30 , tzinfo = ZoneInfo ("Europe/London" ))
208208 event .add ("SUMMARY" , "Test Event" )
209209 calendar .add_component (event )
210-
210+
211211 calendar .add_missing_timezones ()
212-
212+
213213 components = [comp .name for comp in calendar .subcomponents ]
214214 assert components == ["VTIMEZONE" , "VEVENT" ]
215215 assert len (calendar .timezones ) == 1
216216 assert calendar .timezones [0 ].tz_name == "Europe/London"
217-
217+
218218 finally :
219219 # Restore original pytz state
220220 if original_pytz :
221- sys .modules [' pytz' ] = original_pytz
221+ sys .modules [" pytz" ] = original_pytz
222222 else :
223- sys .modules .pop (' pytz' , None )
223+ sys .modules .pop (" pytz" , None )
0 commit comments