Skip to content

Commit 64bda68

Browse files
committed
refactor: use tmp_path fixture for temporary files in tests
1 parent a6b9b94 commit 64bda68

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/pytest_examples/test_custom_environment.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import os
66
import time
7+
import pytest
78

89

910
def test_environment_variables(session):
@@ -42,7 +43,7 @@ def test_environment_variables(session):
4243
assert any("Combined: value1 and value2" in line for line in output)
4344

4445

45-
def test_directory_navigation(session):
46+
def test_directory_navigation(session, tmp_path):
4647
"""Test navigating directories in tmux."""
4748
# Create a window for testing
4849
window = session.new_window(window_name="dir-test")
@@ -52,8 +53,9 @@ def test_directory_navigation(session):
5253
pane.send_keys("clear", enter=True)
5354
time.sleep(0.3)
5455

55-
# Get and save the initial directory
56-
pane.send_keys("pwd > initial_dir.txt", enter=True)
56+
# Get and save the initial directory to tmp_path
57+
initial_dir_file = tmp_path / "initial_dir.txt"
58+
pane.send_keys(f"pwd > {initial_dir_file}", enter=True)
5759
time.sleep(0.5)
5860

5961
# Navigate to /tmp directory

0 commit comments

Comments
 (0)