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
40 41 42 43 44 45 |
|
default_html_report_filename()
¶
The default file 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
48 49 50 51 52 53 |
|
strip_output_tarball_suffix(output)
¶
Strip the '.tar.gz' suffix from the output path.
Source code in src/pytest_plugins/filler/filler.py
56 57 58 59 60 61 62 |
|
is_output_stdout(output)
¶
Returns True if the fixture output is configured to be stdout.
Source code in src/pytest_plugins/filler/filler.py
65 66 67 68 69 |
|
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/filler/filler.py
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 |
|
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
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 264 265 266 |
|
pytest_report_header(config)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/filler/filler.py
269 270 271 272 273 274 275 276 |
|
pytest_report_teststatus(report, config)
¶
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
279 280 281 282 283 284 285 286 287 288 289 290 |
|
pytest_metadata(metadata)
¶
Add or remove metadata to/from the pytest report.
Source code in src/pytest_plugins/filler/filler.py
293 294 295 296 297 |
|
pytest_html_results_table_header(cells)
¶
Customize the table headers of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
300 301 302 303 304 305 306 |
|
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
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
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
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
pytest_html_report_title(report)
¶
Set the HTML report title (pytest-html plugin).
Source code in src/pytest_plugins/filler/filler.py
375 376 377 378 379 |
|
evm_bin(request)
¶
Returns the configured evm tool binary path used to run t8n.
Source code in src/pytest_plugins/filler/filler.py
382 383 384 385 386 387 |
|
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
390 391 392 393 394 395 396 |
|
solc_bin(request)
¶
Returns the configured solc binary path.
Source code in src/pytest_plugins/filler/filler.py
399 400 401 402 403 404 |
|
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/filler/filler.py
407 408 409 410 411 412 413 414 415 416 |
|
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
419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
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
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
base_dump_dir(request)
¶
The base directory to dump the evm debug output.
Source code in src/pytest_plugins/filler/filler.py
461 462 463 464 465 466 467 468 469 |
|
is_output_tarball(request)
¶
Returns True if the output directory is a tarball.
Source code in src/pytest_plugins/filler/filler.py
472 473 474 475 476 477 478 479 480 |
|
output_dir(request, is_output_tarball)
¶
Returns the directory to store the generated test fixtures.
Source code in src/pytest_plugins/filler/filler.py
483 484 485 486 487 488 489 490 491 |
|
create_properties_file(request, output_dir)
¶
Creates an ini file with fixture build properties in the fixture output directory.
Source code in src/pytest_plugins/filler/filler.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 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 |
|
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
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
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
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
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
583 584 585 586 587 588 589 590 591 592 593 |
|
fixture_collector(request, do_fixture_verification, evm_fixture_verification, filler_path, base_dump_dir, output_dir)
¶
Returns the configured fixture collector instance used for all tests in one test module.
Source code in src/pytest_plugins/filler/filler.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
|
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/filler/filler.py
622 623 624 625 626 627 |
|
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/filler/filler.py
630 631 632 633 634 635 636 637 638 639 640 |
|
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/filler/filler.py
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 677 678 679 680 |
|
node_to_test_info(node)
¶
Returns the test info of the current node item.
Source code in src/pytest_plugins/filler/filler.py
686 687 688 689 690 691 692 693 694 695 |
|
fixture_source_url(request)
¶
Returns the URL to the fixture source.
Source code in src/pytest_plugins/filler/filler.py
698 699 700 701 702 703 704 705 706 707 708 709 |
|
fixture_description(request)
¶
Fixture to extract and combine docstrings from the test class and the test function.
Source code in src/pytest_plugins/filler/filler.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
|
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
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 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
|
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
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
|
pytest_collection_modifyitems(config, items)
¶
Remove pre-Paris tests parametrized to generate engine 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
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
|
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/filler/filler.py
863 864 865 866 867 868 |
|
pytest_runtest_call(item)
¶
Pytest hook called in the context of test execution.
Source code in src/pytest_plugins/filler/filler.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
|
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
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 |
|
AllocMode
¶
Bases: IntEnum
Allocation mode for the state.
Source code in src/pytest_plugins/filler/pre_alloc.py
69 70 71 72 73 74 75 |
|
Alloc
¶
Bases: Alloc
Allocation of accounts in the state, pre and post test execution.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 |
|
__init__(*args, alloc_mode, contract_address_iterator, eoa_iterator, **kwargs)
¶
Initializes the allocation with the given properties.
Source code in src/pytest_plugins/filler/pre_alloc.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
__setitem__(address, account)
¶
Sets the account associated with an address.
Source code in src/pytest_plugins/filler/pre_alloc.py
103 104 105 106 107 108 109 |
|
deploy_contract(code, *, storage={}, balance=0, nonce=1, address=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
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 |
|
fund_eoa(amount=10 ** 21, label=None)
¶
Add a previously unused EOA to the pre-alloc with the balance specified by amount
.
Source code in src/pytest_plugins/filler/pre_alloc.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
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
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
alloc_mode(request)
¶
Returns the allocation mode for the tests.
Source code in src/pytest_plugins/filler/pre_alloc.py
191 192 193 194 195 196 197 198 |
|
contract_start_address(request)
¶
Returns the starting address for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
201 202 203 204 205 206 |
|
contract_address_increments(request)
¶
Returns the address increment for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
209 210 211 212 213 214 |
|
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
217 218 219 220 221 222 223 224 225 226 227 |
|
eoa_by_index(i)
cached
¶
Returns an EOA by index.
Source code in src/pytest_plugins/filler/pre_alloc.py
230 231 232 233 234 235 |
|
eoa_iterator()
¶
Returns an iterator over EOAs copies.
Source code in src/pytest_plugins/filler/pre_alloc.py
238 239 240 241 242 243 |
|
pre(alloc_mode, contract_address_iterator, eoa_iterator)
¶
Returns the default pre allocation for all tests (Empty alloc).
Source code in src/pytest_plugins/filler/pre_alloc.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|