Skip to content

Commit 7e83f3f

Browse files
committed
Revert "Move Console Tests to Examples"
This reverts commit 64b3b66.
1 parent 64b3b66 commit 7e83f3f

File tree

3 files changed

+39
-47
lines changed

3 files changed

+39
-47
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-pdm-vcpkg-cmake-simple"
3+
name = "cppython-vcpkg-simple"
44

55
license = {text = "MIT"}
66

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

3-
import shutil
43
from os import walk
54
from pathlib import Path
65
from typing import cast
76

87
import pytest
9-
from typer.testing import CliRunner
10-
11-
from cppython.console.entry import app
12-
13-
runner = CliRunner()
148

159

1610
class TestExamples:
@@ -24,8 +18,7 @@ def _examples() -> list[Path]:
2418
for dirpath, _, filenames in walk('examples'):
2519
for filename in filenames:
2620
if filename == 'pyproject.toml':
27-
absolute_path = Path(dirpath).absolute()
28-
matching_directories.append(absolute_path)
21+
matching_directories.append(Path(dirpath))
2922
break
3023

3124
return matching_directories
@@ -47,43 +40,7 @@ def fixture_example_directory(
4740
return directory
4841

4942
@staticmethod
50-
def test_example_directory(example_directory: Path) -> None:
51-
"""Verify that the fixture is returning the right data"""
43+
def test_example(example_directory: Path) -> None:
44+
"""Tests the examples"""
5245
assert example_directory.is_dir()
5346
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Tests the typer interface type"""
2+
3+
from typer.testing import CliRunner
4+
5+
from cppython.console.entry import app
6+
7+
runner = CliRunner()
8+
9+
10+
class TestConsole:
11+
"""Various tests for the typer interface"""
12+
13+
@staticmethod
14+
def test_info() -> None:
15+
"""Verifies that the info command functions with CPPython hooks"""
16+
result = runner.invoke(app, ['info'])
17+
assert result.exit_code == 0
18+
19+
@staticmethod
20+
def test_list() -> None:
21+
"""Verifies that the list command functions with CPPython hooks"""
22+
result = runner.invoke(app, ['list'])
23+
assert result.exit_code == 0
24+
25+
@staticmethod
26+
def test_update() -> None:
27+
"""Verifies that the update command functions with CPPython hooks"""
28+
result = runner.invoke(app, ['update'])
29+
assert result.exit_code == 0
30+
31+
@staticmethod
32+
def test_install() -> None:
33+
"""Verifies that the install command functions with CPPython hooks"""
34+
result = runner.invoke(app, ['install'])
35+
assert result.exit_code == 0

0 commit comments

Comments
 (0)