11import ast
22import os
33import unittest
4+ from typing import Union
45
56from tests .integration .test_utils import RunSubprocessMixin
67from tests .integration .test_utils import podman_compose_path
@@ -52,14 +53,15 @@ def test_podman_compose_list(self) -> None:
5253 ]
5354
5455 command_down = ["podman" , "rm" , "--force" ]
56+ service : Union [dict [str , str ], str ]
5557
5658 running_containers = []
5759 self .run_subprocess_assert_returncode (command_up )
5860 out , _ = self .run_subprocess_assert_returncode (command_list )
59- out = out .decode ()
61+ str_out = out .decode ()
6062
6163 # Test for table view
62- services = out .strip ().split ("\n " )
64+ services = str_out .strip ().split ("\n " )
6365 headers = [h .strip () for h in services [0 ].split ("\t " )]
6466
6567 for service in services [1 :]:
@@ -74,16 +76,17 @@ def test_podman_compose_list(self) -> None:
7476 # Test for json view
7577 command_list .extend (["--format" , "json" ])
7678 out , _ = self .run_subprocess_assert_returncode (command_list )
77- out = out .decode ()
78- services = ast .literal_eval (out )
79+ str_out = out .decode ()
80+ json_services : list [dict ] = ast .literal_eval (str_out )
81+ self .assertIsInstance (json_services , list )
7982
80- for service in services :
83+ for service in json_services :
8184 self .assertIsInstance (service , dict )
8285 self .assertNotEqual (service .get ("Name" ), None )
8386 self .assertNotEqual (service .get ("Status" ), None )
8487 self .assertNotEqual (service .get ("ConfigFiles" ), None )
8588
86- self .assertEqual (len (services ), 3 )
89+ self .assertEqual (len (json_services ), 3 )
8790
8891 # Get container ID to remove it
8992 out , _ = self .run_subprocess_assert_returncode (command_container_id )
0 commit comments