99"""
1010
1111import asyncio
12- from abc import ABCMeta
12+ from abc import ABC
1313from importlib .metadata import entry_points
1414from pathlib import Path
1515from typing import Any , LiteralString
1616
1717import pytest
1818
19- from cppython .core .plugin_schema .generator import Generator , GeneratorPluginGroupData
20- from cppython .core .plugin_schema .provider import Provider , ProviderPluginGroupData
21- from cppython .core .plugin_schema .scm import SCM , SCMPluginGroupData
22- from cppython .core .resolution import resolve_generator , resolve_provider , resolve_scm
19+ from cppython .core .plugin_schema .generator import Generator
20+ from cppython .core .plugin_schema .provider import Provider
21+ from cppython .core .plugin_schema .scm import SCM
2322from cppython .core .schema import (
2423 CorePluginData ,
25- CPPythonPluginData ,
2624 DataPluginGroupData ,
2725 Plugin ,
2826 ProjectConfiguration ,
29- ProjectData ,
3027)
31- from cppython .test .data .mocks import generator_variants , provider_variants , scm_variants
3228from cppython .test .pytest .mixins import (
33- DataPluginTestMixin ,
34- PluginTestMixin ,
29+ GeneratorPluginTestMixin ,
30+ ProviderPluginTestMixin ,
31+ SCMPluginTestMixin ,
3532)
3633from cppython .utility .utility import canonicalize_type
3734
3835
39- class PluginTestValidation :
36+ class _PluginValidation :
4037 """Common validation tests that can be applied to any plugin.
4138
4239 These are generic tests that validate basic plugin behavior regardless
@@ -76,7 +73,7 @@ def test_plugin_name_extraction(plugin_type: type[Plugin]) -> None:
7673 assert len (plugin_type .name ())
7774
7875
79- class DataPluginTestValidation ( PluginTestValidation ):
76+ class _DataPluginValidation ( _PluginValidation ):
8077 """Validation tests specific to data plugins.
8178
8279 These tests validate that data plugins can handle various configuration
@@ -100,48 +97,15 @@ def test_empty_data_construction(
10097 assert plugin , 'The plugin should be able to be constructed with empty data'
10198
10299
103- class ProviderTestContract [T : Provider ](DataPluginTestMixin [T ], DataPluginTestValidation , metaclass = ABCMeta ):
100+ class ProviderUnitTestContract [T : Provider ](ProviderPluginTestMixin [T ], _DataPluginValidation , ABC ):
104101 """Test contract for Provider plugins.
105102
106103 Each Provider plugin should have exactly one test class that inherits from this
107104 to ensure it fulfills all Provider testing requirements.
108105 """
109106
110- @staticmethod
111- @pytest .fixture (name = 'plugin_configuration_type' , scope = 'session' )
112- def fixture_plugin_configuration_type () -> type [ProviderPluginGroupData ]:
113- """Required hook for Provider plugin configuration data generation"""
114- return ProviderPluginGroupData
115-
116- @staticmethod
117- @pytest .fixture (name = 'plugin_group_data' )
118- def fixture_plugin_group_data (
119- project_data : ProjectData , cppython_plugin_data : CPPythonPluginData
120- ) -> ProviderPluginGroupData :
121- """Generate Provider plugin configuration data"""
122- return resolve_provider (project_data = project_data , cppython_data = cppython_plugin_data )
123-
124- # Cross-plugin testing fixtures for ensuring compatibility
125- @staticmethod
126- @pytest .fixture (name = 'provider_type' , scope = 'session' , params = provider_variants )
127- def fixture_provider_type (plugin_type : type [T ]) -> type [T ]:
128- """Return this provider type for cross-plugin testing"""
129- return plugin_type
130-
131- @staticmethod
132- @pytest .fixture (name = 'generator_type' , scope = 'session' , params = generator_variants )
133- def fixture_generator_type (request : pytest .FixtureRequest ) -> type [Generator ]:
134- """Provide generator variants for cross-plugin testing"""
135- return request .param
136-
137- @staticmethod
138- @pytest .fixture (name = 'scm_type' , scope = 'session' , params = scm_variants )
139- def fixture_scm_type (request : pytest .FixtureRequest ) -> type [SCM ]:
140- """Provide SCM variants for cross-plugin testing"""
141- return request .param
142-
143107
144- class ProviderIntegrationTestContract [T : Provider ](ProviderTestContract [T ], metaclass = ABCMeta ):
108+ class ProviderIntegrationTestContract [T : Provider ](ProviderPluginTestMixin [T ], ABC ):
145109 """Integration test contract for Provider plugins.
146110
147111 Providers that need integration testing should inherit from this contract.
@@ -184,48 +148,15 @@ def test_group_name(plugin_type: type[T]) -> None:
184148 assert canonicalize_type (plugin_type ).group == 'provider'
185149
186150
187- class GeneratorTestContract [T : Generator ](DataPluginTestMixin [T ], DataPluginTestValidation , metaclass = ABCMeta ):
151+ class GeneratorUnitTestContract [T : Generator ](GeneratorPluginTestMixin [T ], _DataPluginValidation , ABC ):
188152 """Test contract for Generator plugins.
189153
190154 Each Generator plugin should have exactly one test class that inherits from this
191155 to ensure it fulfills all Generator testing requirements.
192156 """
193157
194- @staticmethod
195- @pytest .fixture (name = 'plugin_configuration_type' , scope = 'session' )
196- def fixture_plugin_configuration_type () -> type [GeneratorPluginGroupData ]:
197- """Required hook for Generator plugin configuration data generation"""
198- return GeneratorPluginGroupData
199158
200- @staticmethod
201- @pytest .fixture (name = 'plugin_group_data' )
202- def fixture_plugin_group_data (
203- project_data : ProjectData , cppython_plugin_data : CPPythonPluginData
204- ) -> GeneratorPluginGroupData :
205- """Generate Generator plugin configuration data"""
206- return resolve_generator (project_data = project_data , cppython_data = cppython_plugin_data )
207-
208- # Cross-plugin testing fixtures for ensuring compatibility
209- @staticmethod
210- @pytest .fixture (name = 'provider_type' , scope = 'session' , params = provider_variants )
211- def fixture_provider_type (request : pytest .FixtureRequest ) -> type [Provider ]:
212- """Provide provider variants for cross-plugin testing"""
213- return request .param
214-
215- @staticmethod
216- @pytest .fixture (name = 'generator_type' , scope = 'session' )
217- def fixture_generator_type (plugin_type : type [T ]) -> type [T ]:
218- """Return this generator type for cross-plugin testing"""
219- return plugin_type
220-
221- @staticmethod
222- @pytest .fixture (name = 'scm_type' , scope = 'session' , params = scm_variants )
223- def fixture_scm_type (request : pytest .FixtureRequest ) -> type [SCM ]:
224- """Provide SCM variants for cross-plugin testing"""
225- return request .param
226-
227-
228- class GeneratorIntegrationTestContract [T : Generator ](GeneratorTestContract [T ], metaclass = ABCMeta ):
159+ class GeneratorIntegrationTestContract [T : Generator ](GeneratorPluginTestMixin [T ], ABC ):
229160 """Integration test contract for Generator plugins.
230161
231162 Generators that need integration testing should inherit from this contract.
@@ -249,48 +180,15 @@ def test_group_name(plugin_type: type[T]) -> None:
249180 assert canonicalize_type (plugin_type ).group == 'generator'
250181
251182
252- class SCMTestContract [T : SCM ](PluginTestMixin [T ], PluginTestValidation , metaclass = ABCMeta ):
183+ class SCMUnitTestContract [T : SCM ](SCMPluginTestMixin [T ], _PluginValidation , ABC ):
253184 """Test contract for SCM plugins.
254185
255186 Each SCM plugin should have exactly one test class that inherits from this
256187 to ensure it fulfills all SCM testing requirements.
257188 """
258189
259- @staticmethod
260- @pytest .fixture (name = 'plugin_configuration_type' , scope = 'session' )
261- def fixture_plugin_configuration_type () -> type [SCMPluginGroupData ]:
262- """Required hook for SCM plugin configuration data generation"""
263- return SCMPluginGroupData
264-
265- @staticmethod
266- @pytest .fixture (name = 'plugin_group_data' )
267- def fixture_plugin_group_data (
268- project_data : ProjectData , cppython_plugin_data : CPPythonPluginData
269- ) -> SCMPluginGroupData :
270- """Generate SCM plugin configuration data"""
271- return resolve_scm (project_data = project_data , cppython_data = cppython_plugin_data )
272-
273- # Cross-plugin testing fixtures for ensuring compatibility
274- @staticmethod
275- @pytest .fixture (name = 'provider_type' , scope = 'session' , params = provider_variants )
276- def fixture_provider_type (request : pytest .FixtureRequest ) -> type [Provider ]:
277- """Provide provider variants for cross-plugin testing"""
278- return request .param
279-
280- @staticmethod
281- @pytest .fixture (name = 'generator_type' , scope = 'session' , params = generator_variants )
282- def fixture_generator_type (request : pytest .FixtureRequest ) -> type [Generator ]:
283- """Provide generator variants for cross-plugin testing"""
284- return request .param
285-
286- @staticmethod
287- @pytest .fixture (name = 'scm_type' , scope = 'session' , params = scm_variants )
288- def fixture_scm_type (plugin_type : type [T ]) -> type [T ]:
289- """Return this SCM type for cross-plugin testing"""
290- return plugin_type
291-
292190
293- class SCMIntegrationTestContract [T : SCM ](SCMTestContract [T ], metaclass = ABCMeta ):
191+ class SCMIntegrationTestContract [T : SCM ](SCMPluginTestMixin [T ], ABC ):
294192 """Integration test contract for SCM plugins.
295193
296194 SCM plugins that need integration testing should inherit from this contract.
0 commit comments