File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2220,35 +2220,26 @@ def setUp(self):
22202220
22212221 def count_running_containers (self ):
22222222 """Count containers created by this test using Docker client directly."""
2223- # Use Docker client to find containers with SAM CLI labels
22242223 try :
2225- # Get running containers with SAM CLI lambda container label
22262224 sam_containers = self .docker_client .containers .list (
22272225 all = False , filters = {"label" : "sam.cli.container.type=lambda" }
22282226 )
22292227
2230- # Filter by our test's mode environment variable if possible
22312228 test_containers = []
22322229 for container in sam_containers :
22332230 try :
22342231 container .reload ()
22352232 env_vars = container .attrs .get ("Config" , {}).get ("Env" , [])
22362233 for env_var in env_vars :
2237- if env_var . startswith ( "MODE=" ) and self .mode_env_variable in env_var :
2234+ if env_var == f "MODE={ self .mode_env_variable } " :
22382235 test_containers .append (container )
22392236 break
22402237 except Exception :
22412238 continue
22422239
2243- # If we found containers with our mode variable, return that count
2244- if test_containers :
2245- return len (test_containers )
2240+ return len (test_containers )
22462241
2247- # Otherwise, return all SAM containers (fallback)
2248- return len (sam_containers )
2249-
2250- except Exception as e :
2251- # If we can't access Docker client, fall back to 0
2242+ except Exception :
22522243 return 0
22532244
22542245 def _parse_container_ids_from_output (self ):
Original file line number Diff line number Diff line change @@ -403,35 +403,26 @@ def setUp(self):
403403
404404 def count_running_containers (self ):
405405 """Count containers created by this test using Docker client directly."""
406- # Use Docker client to find containers with SAM CLI labels
407406 try :
408- # Get running containers with SAM CLI lambda container label
409407 sam_containers = self .docker_client .containers .list (
410408 all = False , filters = {"label" : "sam.cli.container.type=lambda" }
411409 )
412410
413- # Filter by our test's mode environment variable if possible
414411 test_containers = []
415412 for container in sam_containers :
416413 try :
417414 container .reload ()
418415 env_vars = container .attrs .get ("Config" , {}).get ("Env" , [])
419416 for env_var in env_vars :
420- if env_var . startswith ( "MODE=" ) and self .mode_env_variable in env_var :
417+ if env_var == f "MODE={ self .mode_env_variable } " :
421418 test_containers .append (container )
422419 break
423420 except Exception :
424421 continue
425422
426- # If we found containers with our mode variable, return that count
427- if test_containers :
428- return len (test_containers )
423+ return len (test_containers )
429424
430- # Otherwise, return all SAM containers (fallback)
431- return len (sam_containers )
432-
433- except Exception as e :
434- # If we can't access Docker client, fall back to 0
425+ except Exception :
435426 return 0
436427
437428 def _parse_container_ids_from_output (self ):
You can’t perform that action at this time.
0 commit comments