From cdf35cd12238f6bde68a2fa1269be1660627a2dc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 16 Jul 2023 09:02:35 -0300 Subject: [PATCH] refac --- tests/test_repomap.py | 15 +-------------- tests/utils.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 tests/utils.py diff --git a/tests/test_repomap.py b/tests/test_repomap.py index dc68a4d9d..b34593221 100644 --- a/tests/test_repomap.py +++ b/tests/test_repomap.py @@ -1,24 +1,11 @@ import os -import tempfile import unittest from unittest.mock import patch from aider.io import InputOutput from aider.repomap import RepoMap - -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) +from .utils import IgnorantTemporaryDirectory class TestRepoMap(unittest.TestCase): diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 000000000..1629c4425 --- /dev/null +++ b/tests/utils.py @@ -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)