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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
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
121 122 123 124 125 126 | |
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
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
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
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
__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
169 170 171 172 173 174 175 176 177 178 179 180 181 | |
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
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
runtest()
¶
Define the test to execute for this item.
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
204 205 206 | |
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
208 209 210 211 212 213 214 215 216 | |
pytest_collection_modifyitems(config, items)
¶
Insert a new test EIPSpecTestItem for every test module with 'eip' in its path.
Source code in packages/testing/src/execution_testing/cli/pytest_commands/plugins/spec_version_checker/spec_version_checker.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |