@@ -319,9 +319,11 @@ async def test_health_check(self, adapter: CloudEventsAdapter) -> None:
319319 },
320320 )
321321 def test_convert_to_cloudevent_with_overrides (
322- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
322+ self , config : CloudEventsConfig , sample_event : NotificationEvent
323323 ) -> None :
324324 """Test CloudEvent conversion with K_CE_OVERRIDES."""
325+ # Create adapter after environment variable is set
326+ adapter = CloudEventsAdapter (config )
325327 cloud_event = adapter ._convert_to_cloudevent (sample_event )
326328
327329 assert isinstance (cloud_event , CloudEvent )
@@ -330,18 +332,22 @@ def test_convert_to_cloudevent_with_overrides(
330332
331333 @patch .dict (os .environ , {"K_CE_OVERRIDES" : '{"extensions": {"number": 123}}' })
332334 def test_convert_to_cloudevent_with_number_override (
333- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
335+ self , config : CloudEventsConfig , sample_event : NotificationEvent
334336 ) -> None :
335337 """Test CloudEvent conversion with number in K_CE_OVERRIDES."""
338+ # Create adapter after environment variable is set
339+ adapter = CloudEventsAdapter (config )
336340 cloud_event = adapter ._convert_to_cloudevent (sample_event )
337341
338342 assert cloud_event ["number" ] == "123" # Should be converted to string
339343
340344 @patch .dict (os .environ , {"K_CE_OVERRIDES" : "invalid-json" })
341345 def test_convert_to_cloudevent_invalid_overrides (
342- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
346+ self , config : CloudEventsConfig , sample_event : NotificationEvent
343347 ) -> None :
344348 """Test CloudEvent conversion with invalid K_CE_OVERRIDES JSON."""
349+ # Create adapter after environment variable is set
350+ adapter = CloudEventsAdapter (config )
345351 cloud_event = adapter ._convert_to_cloudevent (sample_event )
346352
347353 # Should work normally without overrides
@@ -350,9 +356,11 @@ def test_convert_to_cloudevent_invalid_overrides(
350356
351357 @patch .dict (os .environ , {"K_CE_OVERRIDES" : '{"other": "field"}' })
352358 def test_convert_to_cloudevent_no_extensions (
353- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
359+ self , config : CloudEventsConfig , sample_event : NotificationEvent
354360 ) -> None :
355361 """Test CloudEvent conversion with K_CE_OVERRIDES but no extensions field."""
362+ # Create adapter after environment variable is set
363+ adapter = CloudEventsAdapter (config )
356364 cloud_event = adapter ._convert_to_cloudevent (sample_event )
357365
358366 # Should work normally without extensions
0 commit comments