11"""Example folder tests"""
22
3- import shutil
43from os import walk
54from pathlib import Path
65from typing import cast
76
87import pytest
9- from typer .testing import CliRunner
10-
11- from cppython .console .entry import app
12-
13- runner = CliRunner ()
148
159
1610class 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
0 commit comments