Skip to content

Commit b89ce8d

Browse files
authored
chore: remove git directory after tests (#484)
1 parent 2fd4404 commit b89ce8d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/ragbits-document-search/tests/integration/test_git_source.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shutil
23
from pathlib import Path
34

45
import pytest
@@ -14,6 +15,18 @@
1415
TEST_REPO_SSH_URL = "git@github.com:psf/requests.git"
1516

1617

18+
@pytest.fixture(autouse=True)
19+
def cleanup_test_dirs():
20+
"""Clean up test directories after each test."""
21+
yield
22+
# Get the test directory path
23+
test_dir = Path(__file__).parent
24+
# Remove the git directory if it exists
25+
git_dir = test_dir / "git"
26+
if git_dir.exists():
27+
shutil.rmtree(git_dir)
28+
29+
1730
async def test_git_source_fetch_file():
1831
"""Test fetching a specific file from a git repository."""
1932
# Fetch the README.md file

packages/ragbits-document-search/tests/unit/test_git_source.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shutil
23
from pathlib import Path
34
from unittest.mock import MagicMock, patch
45

@@ -12,6 +13,18 @@
1213
os.environ[LOCAL_STORAGE_DIR_ENV] = Path(__file__).parent.as_posix()
1314

1415

16+
@pytest.fixture(autouse=True)
17+
def cleanup_test_dirs():
18+
"""Clean up test directories after each test."""
19+
yield
20+
# Get the test directory path
21+
test_dir = Path(__file__).parent
22+
# Remove the git directory if it exists
23+
git_dir = test_dir / "git"
24+
if git_dir.exists():
25+
shutil.rmtree(git_dir)
26+
27+
1528
def test_id():
1629
"""Test the ID property for GitSource"""
1730
# Test basic case

0 commit comments

Comments
 (0)