Test Filler Plugin¶
Top-level pytest configuration file providing: - Command-line options, - Test-fixtures that can be used by all test cases, and that modifies pytest hooks in order to fill test specs for all tests and writes the generated fixtures to file.
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/test_filler/test_filler.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 73 74 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 |
|
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 src/pytest_plugins/test_filler/test_filler.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
pytest_report_header(config, start_path)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/test_filler/test_filler.py
149 150 151 152 153 154 155 156 157 |
|
evm_bin(request)
¶
Returns the configured evm tool binary path.
Source code in src/pytest_plugins/test_filler/test_filler.py
160 161 162 163 164 165 |
|
solc_bin(request)
¶
Returns the configured solc binary path.
Source code in src/pytest_plugins/test_filler/test_filler.py
168 169 170 171 172 173 |
|
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/test_filler/test_filler.py
176 177 178 179 180 181 182 183 184 185 |
|
base_test_config(request)
¶
Returns the base test configuration that all tests must use.
Source code in src/pytest_plugins/test_filler/test_filler.py
188 189 190 191 192 193 194 195 |
|
strip_test_prefix(name)
¶
Removes the test prefix from a test case name.
Source code in src/pytest_plugins/test_filler/test_filler.py
198 199 200 201 202 203 204 205 |
|
convert_test_name_to_path(name)
¶
Converts a test name to a path.
Source code in src/pytest_plugins/test_filler/test_filler.py
208 209 210 211 212 |
|
FixtureCollector
¶
Collects all fixtures generated by the test cases.
Source code in src/pytest_plugins/test_filler/test_filler.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
add_fixture(item, fixture)
¶
Adds a fixture to the list of fixtures of a given test case.
Source code in src/pytest_plugins/test_filler/test_filler.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
dump_fixtures()
¶
Dumps all collected fixtures to their respective files.
Source code in src/pytest_plugins/test_filler/test_filler.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
fixture_collector(request)
¶
Returns the configured fixture collector instance used for all tests in one test module.
Source code in src/pytest_plugins/test_filler/test_filler.py
285 286 287 288 289 290 291 292 293 294 295 296 |
|
engine()
¶
Returns the sealEngine used in the generated test fixtures.
Source code in src/pytest_plugins/test_filler/test_filler.py
299 300 301 302 303 304 |
|
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/test_filler/test_filler.py
307 308 309 310 311 312 |
|
eips()
¶
A fixture specifying that, by default, no EIPs should be activated for tests.
This fixture (function) may be redefined in test filler modules in order to overwrite this default and return a list of integers specifying which EIPs should be activated for the tests in scope.
Source code in src/pytest_plugins/test_filler/test_filler.py
315 316 317 318 319 320 321 322 323 324 325 |
|
yul(fork, request)
¶
A fixture that allows contract code to be defined with Yul code.
This fixture defines a class that wraps the ::ethereum_test_tools.Yul class so that upon instantiation within the test case, it provides the test case's current fork parameter. The forks is then available for use in solc's arguments for the Yul code compilation.
Test cases can override the default value by specifying a fixed version with the @pytest.mark.compile_yul_with(FORK) marker.
Source code in src/pytest_plugins/test_filler/test_filler.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
state_test(request, t8n, fork, engine, reference_spec, eips, fixture_collector, base_test_config)
¶
Fixture used to instantiate an auto-fillable StateTest object from within a test function.
Every test that defines a StateTest filler must explicitly specify this fixture in its function arguments and set the StateTestWrapper's spec property.
Implementation detail: It must be scoped on test function level to avoid leakage between tests.
Source code in src/pytest_plugins/test_filler/test_filler.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
blockchain_test(request, t8n, fork, engine, reference_spec, eips, fixture_collector, base_test_config)
¶
Fixture used to define an auto-fillable BlockchainTest analogous to the state_test fixture for StateTests. See the state_test fixture docstring for details.
Source code in src/pytest_plugins/test_filler/test_filler.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
|
pytest_collection_modifyitems(items, config)
¶
A pytest hook called during collection, after all items have been collected.
Here we dynamically apply "state_test" or "blockchain_test" markers to a test if the test function uses the corresponding fixture.
Source code in src/pytest_plugins/test_filler/test_filler.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
pytest_make_parametrize_id(config, val, argname)
¶
Pytest hook called when generating test ids. We use this to generate more readable test ids for the generated tests.
Source code in src/pytest_plugins/test_filler/test_filler.py
450 451 452 453 454 455 |
|
pytest_runtest_call(item)
¶
Pytest hook called in the context of test execution.
Source code in src/pytest_plugins/test_filler/test_filler.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|