Skip to content

Commit dc6e3a8

Browse files
committed
Move Console Tests to Examples
1 parent 4f2bd46 commit dc6e3a8

File tree

3 files changed

+47
-39
lines changed

3 files changed

+47
-39
lines changed

examples/pdm-vcpkg-cmake/simple/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
description = "A simple project showing how to use vcpkg with CPPython"
3-
name = "cppython-vcpkg-simple"
3+
name = "cppython-pdm-vcpkg-cmake-simple"
44

55
license = {text = "MIT"}
66

tests/integration/examples/test_examples.py

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
"""Example folder tests"""
22

3+
import shutil
34
from os import walk
45
from pathlib import Path
56
from typing import cast
67

78
import pytest
9+
from typer.testing import CliRunner
10+
11+
from cppython.console.entry import app
12+
13+
runner = CliRunner()
814

915

1016
class TestExamples:
@@ -18,7 +24,8 @@ def _examples() -> list[Path]:
1824
for dirpath, _, filenames in walk('examples'):
1925
for filename in filenames:
2026
if filename == 'pyproject.toml':
21-
matching_directories.append(Path(dirpath))
27+
absolute_path = Path(dirpath).absolute()
28+
matching_directories.append(absolute_path)
2229
break
2330

2431
return matching_directories
@@ -40,7 +47,43 @@ def fixture_example_directory(
4047
return directory
4148

4249
@staticmethod
43-
def test_example(example_directory: Path) -> None:
44-
"""Tests the examples"""
50+
def test_example_directory(example_directory: Path) -> None:
51+
"""Verify that the fixture is returning the right data"""
4552
assert example_directory.is_dir()
4653
assert (example_directory / 'pyproject.toml').is_file()
54+
55+
@staticmethod
56+
def test_info(example_directory: Path) -> None:
57+
"""Verifies that the info command functions with CPPython hooks"""
58+
with runner.isolated_filesystem() as temp_directory:
59+
shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True)
60+
61+
result = runner.invoke(app, ['info'])
62+
assert result.exit_code == 0
63+
64+
@staticmethod
65+
def test_list(example_directory: Path) -> None:
66+
"""Verifies that the list command functions with CPPython hooks"""
67+
with runner.isolated_filesystem() as temp_directory:
68+
shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True)
69+
70+
result = runner.invoke(app, ['list'])
71+
assert result.exit_code == 0
72+
73+
@staticmethod
74+
def test_update(example_directory: Path) -> None:
75+
"""Verifies that the update command functions with CPPython hooks"""
76+
with runner.isolated_filesystem() as temp_directory:
77+
shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True)
78+
79+
result = runner.invoke(app, ['update'])
80+
assert result.exit_code == 0
81+
82+
@staticmethod
83+
def test_install(example_directory: Path) -> None:
84+
"""Verifies that the install command functions with CPPython hooks"""
85+
with runner.isolated_filesystem() as temp_directory:
86+
shutil.copytree(example_directory, temp_directory, dirs_exist_ok=True)
87+
88+
result = runner.invoke(app, ['install'])
89+
assert result.exit_code == 0

tests/unit/test_console.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)