File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
tests/integration/examples Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1+ """Helpers for working with the filesystem."""
2+
3+ import os
4+ from collections .abc import Generator
5+ from contextlib import contextmanager
6+ from pathlib import Path
7+
8+
9+ @contextmanager
10+ def isolated_filesystem () -> Generator [Path ]:
11+ """Change the current working directory to the given path for the duration of the test."""
12+ old_cwd = os .getcwd ()
13+ os .chdir (path )
14+ try :
15+ yield
16+ finally :
17+ os .chdir (old_cwd )
Original file line number Diff line number Diff line change 33All examples can be run with the CPPython entry-point, and we use the examples as the test data for the CLI.
44"""
55
6+ import shutil
67from pathlib import Path
78
8- pytest_plugins = ['tests.fixtures.example' ]
9+ from cppython .utility .filesystem import isolated_filesystem
10+
11+ pytest_plugins = ['tests.fixtures.utility' ]
912
1013
1114class TestSetup :
@@ -20,7 +23,7 @@ def test_example_directory(example_directory: Path) -> None:
2023 @staticmethod
2124 def test_list (example_directory : Path ) -> None :
2225 """Verifies that the list command functions with CPPython hooks"""
23- with runner . isolated_filesystem () as temp_directory :
26+ with isolated_filesystem () as temp_directory :
2427 shutil .copytree (example_directory , temp_directory , dirs_exist_ok = True )
2528
2629 result = runner .invoke (app , ['list' ])
You can’t perform that action at this time.
0 commit comments