@@ -34,8 +34,10 @@ def run(self, arguments: argparse.Namespace, simulate: bool, **kwargs) -> None:
34
34
all_python_packages = project_configuration .list_automation_packages () + project_configuration .list_python_packages ()
35
35
36
36
self .clean_artifacts (artifact_directory , simulate = simulate )
37
+ self .clean_python_cache (os .path .join ("Automation" , "Setup" ), simulate = simulate )
37
38
for python_package in all_python_packages :
38
39
self .clean_python_package (python_package , simulate = simulate )
40
+ self .clean_pytest_cache (simulate = simulate )
39
41
40
42
41
43
async def run_async (self , arguments : argparse .Namespace , simulate : bool , ** kwargs ) -> None :
@@ -56,7 +58,7 @@ def clean_python_package(self, python_package: PythonPackage, simulate: bool = F
56
58
for directory in directories_to_remove :
57
59
self ._remove_directory (directory , simulate = simulate )
58
60
59
- metadata_file_path = os .path .join (python_package .path_to_sources , "__metadata__.py" )
61
+ metadata_file_path = os .path .join (python_package .path_to_sources , python_package . name_for_file_system , "__metadata__.py" )
60
62
self ._remove_file (metadata_file_path , simulate = simulate )
61
63
62
64
self .clean_python_cache (python_package .path_to_sources , simulate = simulate )
@@ -74,15 +76,22 @@ def clean_python_cache(self, source_directory: str, simulate: bool = False) -> N
74
76
self ._remove_directory (directory , simulate = simulate )
75
77
76
78
79
+ def clean_pytest_cache (self , simulate : bool = False ) -> None :
80
+ directories_to_remove = [ ".pytest_cache" ]
81
+
82
+ for directory in directories_to_remove :
83
+ self ._remove_directory (directory , simulate = simulate )
84
+
85
+
77
86
def _remove_directory (self , directory_to_remove : str , simulate : bool = False ) -> None :
78
87
if os .path .exists (directory_to_remove ):
79
- logger .debug ("Removing directory '%s'" , directory_to_remove )
88
+ logger .debug ("Removing '%s'" , directory_to_remove )
80
89
if not simulate :
81
90
shutil .rmtree (directory_to_remove )
82
91
83
92
84
93
def _remove_file (self , file_to_remove : str , simulate : bool = False ) -> None :
85
94
if os .path .exists (file_to_remove ):
86
- logger .debug ("Removing file '%s'" , file_to_remove )
95
+ logger .debug ("Removing '%s'" , file_to_remove )
87
96
if not simulate :
88
- shutil . rmtree (file_to_remove )
97
+ os . remove (file_to_remove )
0 commit comments