Spec Version Checker Plugin¶
A pytest plugin that verifies the tested version of an EIP specification against the latest version from the ethereum/EIPs Github repository.
A pytest plugin that checks that the spec version specified in test/filler modules matches that of ethereum/EIPs.
pytest_addoption(parser)
¶
Add Github token option to pytest command line options.
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
pytest_configure(config)
¶
Register the plugin's custom markers and process command-line options.
Custom marker registration: https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#registering-custom-markers
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
get_ref_spec_from_module(module, github_token=None)
¶
Return the reference spec object defined in a module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ModuleType
|
The module to extract reference spec from |
required |
github_token
|
Optional[str]
|
Optional GitHub token for API authentication |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the module path contains "eip" and the module does not define a reference spec. |
Returns:
| Name | Type | Description |
|---|---|---|
spec_obj |
None | ReferenceSpec
|
Return None if the module path does not contain "eip", |
None | ReferenceSpec
|
i.e., the module is not required to define a reference spec, otherwise, |
|
None | ReferenceSpec
|
return the ReferenceSpec object as defined by the module. |
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
is_test_for_an_eip(input_string)
¶
Return True if input_string contains an EIP number, i.e., eipNNNN.
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
test_eip_spec_version(module, github_token=None)
¶
Test that the ReferenceSpec object as defined in the test module is not outdated when compared to the remote hash from ethereum/EIPs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
ModuleType
|
Module to test |
required |
github_token
|
Optional[str]
|
Optional GitHub token for API authentication |
None
|
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
EIPSpecTestItem
¶
Bases: Item
Custom pytest test item to test EIP spec versions.
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
__init__(name, parent, **kwargs)
¶
Initialize the test item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the test |
required |
parent
|
Node
|
Parent node |
required |
**kwargs
|
Any
|
Additional keyword arguments |
{}
|
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
from_parent(parent, **kw)
classmethod
¶
Public constructor to define new tests. https://docs.pytest.org/en/latest/reference/reference.html#pytest.nodes.Node.from_parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Node
|
The parent Node |
required |
kw
|
Any
|
Additional keyword arguments (module, github_token) |
{}
|
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
runtest()
¶
Define the test to execute for this item.
reportinfo()
¶
Get location information for this test item to use test reports.
Returns:
| Type | Description |
|---|---|
tuple[str, int, str]
|
A tuple of (path, line_number, description) |
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
pytest_collection_modifyitems(config, items)
¶
Insert a new test EIPSpecTestItem for every test module with 'eip' in its path.