Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Use context manager for auto tmp dirs cleanup #2922

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions tests/flytekit/unit/types/directory/test_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@

@pytest.fixture
def local_tmp_dirs():
# Create a source directory
src_dir = tempfile.TemporaryDirectory()
for file_idx in range(N_FILES_PER_DIR):
with open(Path(src_dir.name) / f"{file_idx}.txt", "w") as f:
f.write(str(file_idx))

# Create an empty directory as the destination
dst_dir = tempfile.TemporaryDirectory()

yield src_dir.name, dst_dir.name
# Create a source and an empty destination directory
with (tempfile.TemporaryDirectory() as src_dir,
tempfile.TemporaryDirectory() as dst_dir):
for file_idx in range(N_FILES_PER_DIR):
with open(Path(src_dir) / f"{file_idx}.txt", "w") as f:
f.write(str(file_idx))

# Cleanup
src_dir.cleanup()
dst_dir.cleanup()
yield src_dir, dst_dir


def test_src_path_with_different_types(local_tmp_dirs) -> None:
Expand Down
Loading