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.
default_output_directory()
¶
The default directory to store the generated test fixtures. Defined as a function to allow for easier testing.
Source code in src/pytest_plugins/filler/filler.py
36 37 38 39 40 41 |
|
default_html_report_file_path()
¶
The default file path to store the generated HTML test report. Defined as a function to allow for easier testing.
Source code in src/pytest_plugins/filler/filler.py
44 45 46 47 48 49 |
|
strip_output_tarball_suffix(output)
¶
Strip the '.tar.gz' suffix from the output path.
Source code in src/pytest_plugins/filler/filler.py
52 53 54 55 56 57 58 |
|
is_output_stdout(output)
¶
Returns True if the fixture output is configured to be stdout.
Source code in src/pytest_plugins/filler/filler.py
61 62 63 64 65 |
|
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/filler/filler.py
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 105 106 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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 |
|
pytest_configure(config)
¶
Pytest hook called after command line options have been parsed and before test collection begins.
Couple of notes: 1. 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
@pytest.hookimpl(tryfirst=True)
is applied to ensure that this hook is called before the pytest-html plugin's pytest_configure to ensure that it uses the modifiedhtmlpath
option.
Source code in src/pytest_plugins/filler/filler.py
202 203 204 205 206 207 208 209 210 211 212 213 214 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 |
|
pytest_report_header(config)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/filler/filler.py
256 257 258 259 260 261 262 |
|
pytest_report_teststatus(report, config)
¶
This hook modifies the test results in pytest's terminal output.
We use this:
- To disable test session progress report if we're writing the JSON
fixtures to stdout to be read by a consume command on stdin. I.e.,
don't write this type of output to the console:
...x...
Source code in src/pytest_plugins/filler/filler.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
pytest_terminal_summary(terminalreporter, exitstatus, config)
¶
Modify pytest's terminal summary to emphasize that no tests were ran.
Emphasize that fixtures have only been filled; they must now be executed to actually run the tests.
Source code in src/pytest_plugins/filler/filler.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
pytest_metadata(metadata)
¶
Add or remove metadata to/from the pytest report.
Source code in src/pytest_plugins/filler/filler.py
308 309 310 311 312 |
|
pytest_html_results_table_header(cells)
¶
Customize the table headers of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
315 316 317 318 319 320 321 |
|
pytest_html_results_table_row(report, cells)
¶
Customize the table rows of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
324 325 326 327 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 354 355 |
|
pytest_runtest_makereport(item, call)
¶
This hook is called when each test is run and a report is being made.
Make each test's fixture json path available to the test report via user_properties.
Source code in src/pytest_plugins/filler/filler.py
358 359 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 |
|
pytest_html_report_title(report)
¶
Set the HTML report title (pytest-html plugin).
Source code in src/pytest_plugins/filler/filler.py
390 391 392 393 394 |
|
evm_bin(request)
¶
Returns the configured evm tool binary path used to run t8n.
Source code in src/pytest_plugins/filler/filler.py
397 398 399 400 401 402 |
|
verify_fixtures_bin(request)
¶
Returns the configured evm tool binary path used to run statetest or blocktest.
Source code in src/pytest_plugins/filler/filler.py
405 406 407 408 409 410 411 |
|
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/filler/filler.py
414 415 416 417 418 419 420 421 422 423 |
|
do_fixture_verification(request, verify_fixtures_bin)
¶
Returns True if evm statetest or evm blocktest should be ran on the generated fixture JSON files.
Source code in src/pytest_plugins/filler/filler.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
|
evm_fixture_verification(do_fixture_verification, evm_bin, verify_fixtures_bin)
¶
Returns the configured evm binary for executing statetest and blocktest commands used to verify generated JSON fixtures.
Source code in src/pytest_plugins/filler/filler.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
base_dump_dir(request)
¶
The base directory to dump the evm debug output.
Source code in src/pytest_plugins/filler/filler.py
468 469 470 471 472 473 474 475 476 477 478 |
|
is_output_tarball(request)
¶
Returns True if the output directory is a tarball.
Source code in src/pytest_plugins/filler/filler.py
481 482 483 484 485 486 487 488 489 |
|
output_dir(request, is_output_tarball)
¶
Returns the directory to store the generated test fixtures.
Source code in src/pytest_plugins/filler/filler.py
492 493 494 495 496 497 498 499 500 |
|
output_metadata_dir(output_dir)
¶
Returns the metadata directory to store fixture meta files.
Source code in src/pytest_plugins/filler/filler.py
503 504 505 506 507 508 |
|
create_properties_file(request, output_dir, output_metadata_dir)
¶
Creates an ini file with fixture build properties in the fixture output directory.
Source code in src/pytest_plugins/filler/filler.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
create_tarball(request, output_dir, is_output_tarball)
¶
Create a tarball of json files the output directory if the configured output ends with '.tar.gz'.
Only include .json and .ini files in the archive.
Source code in src/pytest_plugins/filler/filler.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
dump_dir_parameter_level(request, base_dump_dir, filler_path)
¶
The directory to dump evm transition tool debug output on a test parameter level.
Example with --evm-dump-dir=/tmp/evm: -> /tmp/evm/shanghai__eip3855_push0__test_push0__test_push0_key_sstore/fork_shanghai/
Source code in src/pytest_plugins/filler/filler.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
get_fixture_collection_scope(fixture_name, config)
¶
Return the appropriate scope to write fixture JSON files.
See: https://docs.pytest.org/en/stable/how-to/fixtures.html#dynamic-scope
Source code in src/pytest_plugins/filler/filler.py
604 605 606 607 608 609 610 611 612 613 614 |
|
fixture_collector(request, do_fixture_verification, evm_fixture_verification, filler_path, base_dump_dir, output_dir, session_temp_folder, generate_index)
¶
Returns the configured fixture collector instance used for all tests in one test module.
Source code in src/pytest_plugins/filler/filler.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
|
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/filler/filler.py
679 680 681 682 683 684 |
|
node_to_test_info(node)
¶
Returns the test info of the current node item.
Source code in src/pytest_plugins/filler/filler.py
687 688 689 690 691 692 693 694 695 696 |
|
fixture_source_url(request)
¶
Returns the URL to the fixture source.
Source code in src/pytest_plugins/filler/filler.py
699 700 701 702 703 704 705 706 707 708 709 710 |
|
base_test_parametrizer(cls)
¶
Generates a pytest.fixture for a given BaseTest subclass.
Implementation detail: All spec fixtures must be scoped on test function level to avoid leakage between tests.
Source code in src/pytest_plugins/filler/filler.py
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
|
pytest_generate_tests(metafunc)
¶
Pytest hook used to dynamically generate test cases for each fixture format a given test spec supports.
Source code in src/pytest_plugins/filler/filler.py
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
|
pytest_collection_modifyitems(config, items)
¶
Remove pre-Paris tests parametrized to generate hive type fixtures; these can't be used in the Hive Pyspec Simulator.
This can't be handled in this plugins pytest_generate_tests() as the fork parametrization occurs in the forks plugin.
Source code in src/pytest_plugins/filler/filler.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
|
Pre-alloc specifically conditioned for test filling.
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 |
|
AllocMode
¶
Bases: IntEnum
Allocation mode for the state.
Source code in src/pytest_plugins/filler/pre_alloc.py
82 83 84 85 86 87 88 |
|
Alloc
¶
Bases: Alloc
Allocation of accounts in the state, pre and post test execution.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 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 |
|
__init__(*args, alloc_mode, contract_address_iterator, eoa_iterator, evm_code_type=None, **kwargs)
¶
Initializes the allocation with the given properties.
Source code in src/pytest_plugins/filler/pre_alloc.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
__setitem__(address, account)
¶
Sets the account associated with an address.
Source code in src/pytest_plugins/filler/pre_alloc.py
122 123 124 125 126 127 128 |
|
code_pre_processor(code, *, evm_code_type)
¶
Pre-processes the code before setting it.
Source code in src/pytest_plugins/filler/pre_alloc.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
deploy_contract(code, *, storage={}, balance=0, nonce=1, address=None, evm_code_type=None, label=None)
¶
Deploy a contract to the allocation.
Warning: address
parameter is a temporary solution to allow tests to hard-code the
contract address. Do NOT use in new tests as it will be removed in the future!
Source code in src/pytest_plugins/filler/pre_alloc.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 |
|
fund_eoa(amount=None, label=None, storage=None, delegation=None, nonce=None)
¶
Add a previously unused EOA to the pre-alloc with the balance specified by amount
.
If amount is 0, nothing will be added to the pre-alloc but a new and unique EOA will be returned.
Source code in src/pytest_plugins/filler/pre_alloc.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 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 |
|
fund_address(address, amount)
¶
Fund an address with a given amount.
If the address is already present in the pre-alloc the amount will be added to its existing balance.
Source code in src/pytest_plugins/filler/pre_alloc.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
alloc_mode(request)
¶
Returns the allocation mode for the tests.
Source code in src/pytest_plugins/filler/pre_alloc.py
266 267 268 269 270 271 272 273 |
|
contract_start_address(request)
¶
Returns the starting address for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
276 277 278 279 280 281 |
|
contract_address_increments(request)
¶
Returns the address increment for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
284 285 286 287 288 289 |
|
contract_address_iterator(contract_start_address, contract_address_increments)
¶
Returns an iterator over contract addresses.
Source code in src/pytest_plugins/filler/pre_alloc.py
292 293 294 295 296 297 298 299 300 301 302 |
|
eoa_by_index(i)
cached
¶
Returns an EOA by index.
Source code in src/pytest_plugins/filler/pre_alloc.py
305 306 307 308 309 310 |
|
eoa_iterator()
¶
Returns an iterator over EOAs copies.
Source code in src/pytest_plugins/filler/pre_alloc.py
313 314 315 316 317 318 |
|
evm_code_type(request)
¶
Returns the default EVM code type for all tests (LEGACY).
Source code in src/pytest_plugins/filler/pre_alloc.py
321 322 323 324 325 326 327 328 329 330 |
|
pre(alloc_mode, contract_address_iterator, eoa_iterator, evm_code_type)
¶
Returns the default pre allocation for all tests (Empty alloc).
Source code in src/pytest_plugins/filler/pre_alloc.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|