@@ -262,9 +262,11 @@ async def test_health_check(self, adapter: CloudEventsAdapter) -> None:
262262 },
263263 )
264264 def test_convert_to_cloudevent_with_overrides (
265- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
265+ self , config : CloudEventsConfig , sample_event : NotificationEvent
266266 ) -> None :
267267 """Test CloudEvent conversion with K_CE_OVERRIDES."""
268+ # Create adapter after environment variable is set
269+ adapter = CloudEventsAdapter (config )
268270 cloud_event = adapter ._convert_to_cloudevent (sample_event )
269271
270272 assert isinstance (cloud_event , CloudEvent )
@@ -273,18 +275,22 @@ def test_convert_to_cloudevent_with_overrides(
273275
274276 @patch .dict (os .environ , {"K_CE_OVERRIDES" : '{"extensions": {"number": 123}}' })
275277 def test_convert_to_cloudevent_with_number_override (
276- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
278+ self , config : CloudEventsConfig , sample_event : NotificationEvent
277279 ) -> None :
278280 """Test CloudEvent conversion with number in K_CE_OVERRIDES."""
281+ # Create adapter after environment variable is set
282+ adapter = CloudEventsAdapter (config )
279283 cloud_event = adapter ._convert_to_cloudevent (sample_event )
280284
281285 assert cloud_event ["number" ] == "123" # Should be converted to string
282286
283287 @patch .dict (os .environ , {"K_CE_OVERRIDES" : "invalid-json" })
284288 def test_convert_to_cloudevent_invalid_overrides (
285- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
289+ self , config : CloudEventsConfig , sample_event : NotificationEvent
286290 ) -> None :
287291 """Test CloudEvent conversion with invalid K_CE_OVERRIDES JSON."""
292+ # Create adapter after environment variable is set
293+ adapter = CloudEventsAdapter (config )
288294 cloud_event = adapter ._convert_to_cloudevent (sample_event )
289295
290296 # Should work normally without overrides
@@ -293,9 +299,11 @@ def test_convert_to_cloudevent_invalid_overrides(
293299
294300 @patch .dict (os .environ , {"K_CE_OVERRIDES" : '{"other": "field"}' })
295301 def test_convert_to_cloudevent_no_extensions (
296- self , adapter : CloudEventsAdapter , sample_event : NotificationEvent
302+ self , config : CloudEventsConfig , sample_event : NotificationEvent
297303 ) -> None :
298304 """Test CloudEvent conversion with K_CE_OVERRIDES but no extensions field."""
305+ # Create adapter after environment variable is set
306+ adapter = CloudEventsAdapter (config )
299307 cloud_event = adapter ._convert_to_cloudevent (sample_event )
300308
301309 # Should work normally without extensions
0 commit comments