Skip to content

Commit 6b1f3b6

Browse files
committed
Update example.py
1 parent 7d2ea1e commit 6b1f3b6

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

tests/fixtures/example.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ def fixture_example_directory(
4848
def fixture_example_runner(
4949
request: pytest.FixtureRequest, typer_runner: CliRunner, tmp_path: Path
5050
) -> Generator[CliRunner]:
51-
"""TODO"""
52-
prev_cwd = os.getcwd()
53-
51+
"""Sets up an isolated filesystem for an example test."""
5452
# Get the root directory of the project
5553
root_directory = Path(__file__).parent.parent.parent.absolute()
5654

@@ -63,13 +61,8 @@ def fixture_example_runner(
6361
# Generate the example path from the pytest file and test name
6462
example_path = root_directory / 'examples' / file_name / test_name
6563

66-
try:
67-
with typer_runner.isolated_filesystem(tmp_path) as temp_directory:
68-
os.chdir(temp_directory)
69-
70-
# Copy the example directory to the temporary directory
71-
shutil.copytree(example_path, Path(), dirs_exist_ok=True)
64+
with typer_runner.isolated_filesystem(temp_dir=tmp_path):
65+
# Copy the example directory to the temporary directory
66+
shutil.copytree(example_path, Path(), dirs_exist_ok=True)
7267

73-
yield typer_runner
74-
finally:
75-
os.chdir(prev_cwd)
68+
yield typer_runner

0 commit comments

Comments
 (0)