forked from cleveragents/cleveragents-core
49 lines
2.6 KiB
Gherkin
49 lines
2.6 KiB
Gherkin
Feature: Plugin Loader Coverage Boost
|
|
Scenarios targeting uncovered lines in the PluginLoader class:
|
|
- Lines 203-209: entry point load failure exception handler
|
|
- Lines 242, 244-246: validate_protocol fallback to issubclass when instantiation fails
|
|
- Lines 247-248: validate_protocol issubclass raises TypeError
|
|
|
|
Background:
|
|
Given the plugin loader module is imported
|
|
|
|
# -----------------------------------------------------------------------
|
|
# Entry-point discovery: failure path (lines 203-209)
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: Entry point that fails to load is skipped with a warning
|
|
Given the entry points are mocked with one that raises on load
|
|
When I call load_from_entry_points
|
|
Then the plugin result should be an empty descriptor list
|
|
And the failed entry point should have been logged as a warning
|
|
|
|
# -----------------------------------------------------------------------
|
|
# validate_protocol: instantiation fails, issubclass succeeds (lines 242, 244-246)
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: validate_protocol falls back to issubclass when instantiation fails
|
|
Given I have a class that requires constructor arguments
|
|
And I have a runtime checkable protocol the class satisfies via issubclass
|
|
When I call validate_protocol with the non-instantiable class and protocol
|
|
Then validate_protocol should return True
|
|
|
|
# -----------------------------------------------------------------------
|
|
# validate_protocol: instantiation fails, issubclass raises TypeError (lines 247-248)
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: validate_protocol raises ProtocolMismatchError when issubclass raises TypeError
|
|
Given I have a class that cannot be instantiated without arguments
|
|
And I have a protocol-like object that causes issubclass to raise TypeError
|
|
When I call validate_protocol expecting a mismatch error
|
|
Then a plugin-loader ProtocolMismatchError should be raised
|
|
|
|
# -----------------------------------------------------------------------
|
|
# validate_protocol: instantiation fails, issubclass returns False
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: validate_protocol raises ProtocolMismatchError when issubclass returns False
|
|
Given I have a class that cannot be instantiated without arguments
|
|
And I have a runtime checkable protocol the class does not satisfy
|
|
When I call validate_protocol expecting a mismatch error
|
|
Then a plugin-loader ProtocolMismatchError should be raised
|