mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
Ignore errors when cleaning up temp dirs (Win)
This commit is contained in:
parent
8e2b92febb
commit
b52a62190a
2 changed files with 20 additions and 4 deletions
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from aider.io import InputOutput
|
||||
from aider.repomap import RepoMap
|
||||
|
||||
from .utils import IgnorantTemporaryDirectory
|
||||
|
||||
|
||||
class TestRepoMap(unittest.TestCase):
|
||||
def test_get_repo_map(self):
|
||||
|
@ -17,7 +18,7 @@ class TestRepoMap(unittest.TestCase):
|
|||
"test_file4.json",
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with IgnorantTemporaryDirectory() as temp_dir:
|
||||
for file in test_files:
|
||||
with open(os.path.join(temp_dir, file), "w") as f:
|
||||
f.write("")
|
||||
|
@ -60,7 +61,7 @@ print(my_function(3, 4))
|
|||
test_file3 = "test_file_pass.py"
|
||||
file_content3 = "pass"
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with IgnorantTemporaryDirectory() as temp_dir:
|
||||
with open(os.path.join(temp_dir, test_file1), "w") as f:
|
||||
f.write(file_content1)
|
||||
|
||||
|
@ -124,7 +125,7 @@ print(my_function(3, 4))
|
|||
"test_file6.js",
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with IgnorantTemporaryDirectory() as temp_dir:
|
||||
for file in test_files:
|
||||
with open(os.path.join(temp_dir, file), "w") as f:
|
||||
f.write("")
|
||||
|
|
15
tests/utils.py
Normal file
15
tests/utils.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import tempfile
|
||||
|
||||
|
||||
class IgnorantTemporaryDirectory:
|
||||
def __init__(self):
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
|
||||
def __enter__(self):
|
||||
return self.temp_dir.__enter__()
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
try:
|
||||
self.temp_dir.__exit__(exc_type, exc_val, exc_tb)
|
||||
except OSError:
|
||||
pass # Ignore errors (Windows)
|
Loading…
Add table
Add a link
Reference in a new issue