Coverage for skema/program_analysis/tests/utils_test.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1from pathlib import Path 

2 

3# Create a temp file to store the program being tested 

4def create_temp_file(file_content_string, extension): 

5 temp_file = open(f"temp.{extension}", "w") 

6 temp_file.write(file_content_string) 

7 temp_file.close() 

8 

9# Attempt to delete the temp file, if it exists 

10def delete_temp_file(extension): 

11 temp_file_path = Path(f"temp.{extension}") 

12 if temp_file_path.exists(): 

13 temp_file_path.unlink() 

14 

15# Simple testing 

16def main(): 

17 create_temp_file("x = 2", "py") 

18 print(Path("temp.py").exists()) 

19 

20 delete_temp_file("py") 

21 print(Path("temp.py").exists()) 

22 

23main()