@@ -80,6 +80,17 @@ def _docker_compose_down(self):
8080 self ._docker_is_up = False
8181 return run
8282
83+ def _docker_fix_permissions_for_cleanup (self , service , path ):
84+ """Fix permissions on container-created files to allow temp directory cleanup.
85+
86+ Docker containers may create files with different ownership that the
87+ test process cannot delete. This chmod's them before stopping containers.
88+ """
89+ try :
90+ self ._docker_compose ('exec' , '-T' , service , 'chmod' , '-R' , '777' , path )
91+ except Exception :
92+ pass # Best effort - container might not be running
93+
8394 def _print_container_versions (self ):
8495 """Print the versions of the containers being used for debugging.
8596
@@ -117,11 +128,8 @@ def tearDown(self):
117128 if hasattr (self , '_docker_is_up' ) and self ._docker_is_up :
118129 # Fix permissions on files created by containers before stopping them
119130 # This allows the temp directory cleanup to work properly
120- try :
121- self ._docker_compose ('exec' , '-T' , 'appdaemon' ,
122- 'chmod' , '-R' , '777' , '/conf' )
123- except Exception :
124- pass # Best effort - container might not be running
131+ self ._docker_fix_permissions_for_cleanup ('appdaemon' , '/conf' )
132+ self ._docker_fix_permissions_for_cleanup ('homeassistant' , '/config' )
125133
126134 # Stop and destroy containers
127135 self ._docker_compose_down ()
0 commit comments