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
41 42 43 44 45 46 |
|
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
49 50 51 52 53 54 |
|
strip_output_tarball_suffix(output)
¶
Strip the '.tar.gz' suffix from the output path.
Source code in src/pytest_plugins/filler/filler.py
57 58 59 60 61 62 63 |
|
is_output_stdout(output)
¶
Returns True if the fixture output is configured to be stdout.
Source code in src/pytest_plugins/filler/filler.py
66 67 68 69 70 |
|
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/filler/filler.py
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 200 201 202 |
|
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
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 267 268 269 270 271 272 |
|
pytest_report_header(config)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/filler/filler.py
275 276 277 278 279 280 281 282 |
|
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
285 286 287 288 289 290 291 292 293 294 295 296 |
|
pytest_metadata(metadata)
¶
Add or remove metadata to/from the pytest report.
Source code in src/pytest_plugins/filler/filler.py
299 300 301 302 303 |
|
pytest_html_results_table_header(cells)
¶
Customize the table headers of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
306 307 308 309 310 311 312 |
|
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
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 341 342 343 344 345 346 |
|
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
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
pytest_html_report_title(report)
¶
Set the HTML report title (pytest-html plugin).
Source code in src/pytest_plugins/filler/filler.py
381 382 383 384 385 |
|
evm_bin(request)
¶
Returns the configured evm tool binary path used to run t8n.
Source code in src/pytest_plugins/filler/filler.py
388 389 390 391 392 393 |
|
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
396 397 398 399 400 401 402 |
|
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/filler/filler.py
405 406 407 408 409 410 411 412 413 414 |
|
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
417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
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
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
|
base_dump_dir(request)
¶
The base directory to dump the evm debug output.
Source code in src/pytest_plugins/filler/filler.py
459 460 461 462 463 464 465 466 467 |
|
is_output_tarball(request)
¶
Returns True if the output directory is a tarball.
Source code in src/pytest_plugins/filler/filler.py
470 471 472 473 474 475 476 477 478 |
|
output_dir(request, is_output_tarball)
¶
Returns the directory to store the generated test fixtures.
Source code in src/pytest_plugins/filler/filler.py
481 482 483 484 485 486 487 488 489 |
|
output_metadata_dir(output_dir)
¶
Returns the metadata directory to store fixture meta files.
Source code in src/pytest_plugins/filler/filler.py
492 493 494 495 496 497 |
|
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
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 536 537 538 539 540 541 542 543 544 545 |
|
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
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
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
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
|
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
593 594 595 596 597 598 599 600 601 602 603 |
|
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
616 617 618 619 620 621 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 |
|
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/filler/filler.py
673 674 675 676 677 678 |
|
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
681 682 683 684 685 686 687 688 689 690 691 |
|
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
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 |
|
node_to_test_info(node)
¶
Returns the test info of the current node item.
Source code in src/pytest_plugins/filler/filler.py
737 738 739 740 741 742 743 744 745 746 |
|
fixture_source_url(request)
¶
Returns the URL to the fixture source.
Source code in src/pytest_plugins/filler/filler.py
749 750 751 752 753 754 755 756 757 758 759 760 |
|
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
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
|
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
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 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 842 843 844 845 846 847 848 849 850 851 852 853 |
|
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
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
|
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
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
|
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
915 916 917 918 919 920 |
|
pytest_runtest_call(item)
¶
Pytest hook called in the context of test execution.
Source code in src/pytest_plugins/filler/filler.py
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
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 |
|
AllocMode
¶
Bases: IntEnum
Allocation mode for the state.
Source code in src/pytest_plugins/filler/pre_alloc.py
80 81 82 83 84 85 86 |
|
Alloc
¶
Bases: Alloc
Allocation of accounts in the state, pre and post test execution.
Source code in src/pytest_plugins/filler/pre_alloc.py
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 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 |
|
__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
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
__setitem__(address, account)
¶
Sets the account associated with an address.
Source code in src/pytest_plugins/filler/pre_alloc.py
120 121 122 123 124 125 126 |
|
code_pre_processor(code, *, evm_code_type)
¶
Pre-processes the code before setting it.
Source code in src/pytest_plugins/filler/pre_alloc.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
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
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 |
|
fund_eoa(amount=10 ** 21, label=None, storage=None, delegation=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
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 |
|
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
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
alloc_mode(request)
¶
Returns the allocation mode for the tests.
Source code in src/pytest_plugins/filler/pre_alloc.py
247 248 249 250 251 252 253 254 |
|
contract_start_address(request)
¶
Returns the starting address for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
257 258 259 260 261 262 |
|
contract_address_increments(request)
¶
Returns the address increment for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
265 266 267 268 269 270 |
|
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
273 274 275 276 277 278 279 280 281 282 283 |
|
eoa_by_index(i)
cached
¶
Returns an EOA by index.
Source code in src/pytest_plugins/filler/pre_alloc.py
286 287 288 289 290 291 |
|
eoa_iterator()
¶
Returns an iterator over EOAs copies.
Source code in src/pytest_plugins/filler/pre_alloc.py
294 295 296 297 298 299 |
|
evm_code_type(request)
¶
Returns the default EVM code type for all tests (LEGACY).
Source code in src/pytest_plugins/filler/pre_alloc.py
302 303 304 305 306 307 308 309 310 311 |
|
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
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|