File tree Expand file tree Collapse file tree 6 files changed +66
-43
lines changed
integration/plugins/cmake Expand file tree Collapse file tree 6 files changed +66
-43
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,17 @@ def sync(self, sync_data: SyncData) -> None:
6060 Args:
6161 sync_data: The input data
6262 """
63- if isinstance (sync_data , CMakeSyncData ):
64- self ._cppython_preset_directory .mkdir (parents = True , exist_ok = True )
65- self ._provider_directory .mkdir (parents = True , exist_ok = True )
63+ match sync_data :
64+ case CMakeSyncData ():
65+ self ._cppython_preset_directory .mkdir (parents = True , exist_ok = True )
66+ self ._provider_directory .mkdir (parents = True , exist_ok = True )
6667
67- self .builder .write_provider_preset (self ._provider_directory , sync_data )
68+ self .builder .write_provider_preset (self ._provider_directory , sync_data )
6869
69- cppython_preset_file = self .builder .write_cppython_preset (
70- self ._cppython_preset_directory , self ._provider_directory , sync_data
71- )
70+ cppython_preset_file = self .builder .write_cppython_preset (
71+ self ._cppython_preset_directory , self ._provider_directory , sync_data
72+ )
7273
73- self .builder .write_root_presets (self .data .preset_file , cppython_preset_file )
74+ self .builder .write_root_presets (self .data .preset_file , cppython_preset_file )
75+ case _:
76+ raise ValueError ('Unsupported sync data type' )
Original file line number Diff line number Diff line change 1- """Data variations for testing """
1+ """Global fixtures for the test suite """
22
33# from pathlib import Path
44from pathlib import Path
2828 PyProject ,
2929 ToolData ,
3030)
31- from cppython .plugins .cmake .schema import CMakeConfiguration
3231from cppython .test .pytest .variants import (
3332 cppython_global_variants ,
3433 cppython_local_variants ,
3736)
3837
3938
40- def _cmake_data_list () -> list [CMakeConfiguration ]:
41- """Creates a list of mocked configuration types
42-
43- Returns:
44- A list of variants to test
45- """
46- variants = []
47-
48- # Default
49- variants .append (CMakeConfiguration (configuration_name = 'default' ))
50-
51- # variants.append(CMakeConfiguration(preset_file=Path("inner/CMakePresets.json"), configuration_name="default"))
52-
53- return variants
54-
55-
5639@pytest .fixture (
5740 name = 'install_path' ,
5841 scope = 'session' ,
@@ -311,23 +294,6 @@ def fixture_project(
311294 return PyProject (project = pep621_configuration , tool = tool )
312295
313296
314- @pytest .fixture (
315- name = 'cmake_data' ,
316- scope = 'session' ,
317- params = _cmake_data_list (),
318- )
319- def fixture_cmake_data (request : pytest .FixtureRequest ) -> CMakeConfiguration :
320- """A fixture to provide a list of configuration types
321-
322- Args:
323- request: Parameterization list
324-
325- Returns:
326- A configuration type instance
327- """
328- return cast (CMakeConfiguration , request .param )
329-
330-
331297def pytest_generate_tests (metafunc : pytest .Metafunc ) -> None :
332298 """Provides custom parameterization for dynamic fixture names.
333299
Original file line number Diff line number Diff line change 1+ """Fixtures for tests.
2+
3+ `pytest_plugins` is the preferred way to load fixtures, to prevent the overhead of a large root conftest file.
4+ The plugins must be defined at the test module's global scope and not in non-root conftest files.
5+
6+ ex.
7+ ```
8+ pytest_plugins = ['fixtures.fixture_name']
9+ ```
10+ """
Original file line number Diff line number Diff line change 1+ """Fixtures for the cmake plugin"""
2+
3+ from typing import cast
4+
5+ import pytest
6+
7+ from cppython .plugins .cmake .schema import CMakeConfiguration
8+
9+
10+ def _cmake_data_list () -> list [CMakeConfiguration ]:
11+ """Creates a list of mocked configuration types
12+
13+ Returns:
14+ A list of variants to test
15+ """
16+ variants = []
17+
18+ # Default
19+ variants .append (CMakeConfiguration (configuration_name = 'default' ))
20+
21+ # variants.append(CMakeConfiguration(preset_file=Path("inner/CMakePresets.json"), configuration_name="default"))
22+
23+ return variants
24+
25+
26+ @pytest .fixture (
27+ name = 'cmake_data' ,
28+ scope = 'session' ,
29+ params = _cmake_data_list (),
30+ )
31+ def fixture_cmake_data (request : pytest .FixtureRequest ) -> CMakeConfiguration :
32+ """A fixture to provide a list of configuration types
33+
34+ Args:
35+ request: Parameterization list
36+
37+ Returns:
38+ A configuration type instance
39+ """
40+ return cast (CMakeConfiguration , request .param )
Original file line number Diff line number Diff line change 88from cppython .plugins .cmake .schema import CMakeConfiguration
99from cppython .test .pytest .tests import GeneratorIntegrationTests
1010
11+ pytest_plugins = ['tests.fixtures.cmake' ]
12+
1113
1214class TestCPPythonGenerator (GeneratorIntegrationTests [CMakeGenerator ]):
1315 """The tests for the CMake generator"""
Original file line number Diff line number Diff line change 1616from cppython .test .pytest .tests import GeneratorUnitTests
1717from cppython .utility .utility import TypeName
1818
19+ pytest_plugins = ['tests.fixtures.cmake' ]
20+
1921
2022class TestCPPythonGenerator (GeneratorUnitTests [CMakeGenerator ]):
2123 """The tests for the CMake generator"""
You can’t perform that action at this time.
0 commit comments