|
1 | 1 | """Tests the typer interface type""" |
2 | 2 |
|
| 3 | +import shutil |
| 4 | +from pathlib import Path |
| 5 | + |
3 | 6 | from typer.testing import CliRunner |
4 | 7 |
|
5 | 8 | from cppython.console.entry import app |
6 | 9 |
|
7 | 10 | runner = CliRunner() |
| 11 | +pytest_plugins = ['tests.fixtures.example'] |
8 | 12 |
|
9 | 13 |
|
10 | 14 | class TestConsole: |
11 | | - """Various tests for the typer interface""" |
| 15 | + """Various that all the examples are accessible to cppython""" |
12 | 16 |
|
13 | 17 | @staticmethod |
14 | | - def test_info() -> None: |
| 18 | + def test_info(example_directory: Path) -> None: |
15 | 19 | """Verifies that the info command functions with CPPython hooks""" |
16 | | - result = runner.invoke(app, ['info']) |
17 | | - assert result.exit_code == 0 |
| 20 | + with runner.isolated_filesystem() as temp_directory: |
| 21 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 22 | + |
| 23 | + result = runner.invoke(app, ['info']) |
| 24 | + assert result.exit_code == 0 |
18 | 25 |
|
19 | 26 | @staticmethod |
20 | | - def test_list() -> None: |
| 27 | + def test_list(example_directory: Path) -> None: |
21 | 28 | """Verifies that the list command functions with CPPython hooks""" |
22 | | - result = runner.invoke(app, ['list']) |
23 | | - assert result.exit_code == 0 |
| 29 | + with runner.isolated_filesystem() as temp_directory: |
| 30 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 31 | + |
| 32 | + result = runner.invoke(app, ['list']) |
| 33 | + assert result.exit_code == 0 |
24 | 34 |
|
25 | 35 | @staticmethod |
26 | | - def test_update() -> None: |
| 36 | + def test_update(example_directory: Path) -> None: |
27 | 37 | """Verifies that the update command functions with CPPython hooks""" |
28 | | - result = runner.invoke(app, ['update']) |
29 | | - assert result.exit_code == 0 |
| 38 | + with runner.isolated_filesystem() as temp_directory: |
| 39 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 40 | + |
| 41 | + result = runner.invoke(app, ['update']) |
| 42 | + assert result.exit_code == 0 |
30 | 43 |
|
31 | 44 | @staticmethod |
32 | | - def test_install() -> None: |
| 45 | + def test_install(example_directory: Path) -> None: |
33 | 46 | """Verifies that the install command functions with CPPython hooks""" |
34 | | - result = runner.invoke(app, ['install']) |
35 | | - assert result.exit_code == 0 |
| 47 | + with runner.isolated_filesystem() as temp_directory: |
| 48 | + shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True) |
| 49 | + |
| 50 | + result = runner.invoke(app, ['install']) |
| 51 | + assert result.exit_code == 0 |
0 commit comments