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
35 36 37 38 39 40 |
|
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
43 44 45 46 47 48 |
|
strip_output_tarball_suffix(output)
¶
Strip the '.tar.gz' suffix from the output path.
Source code in src/pytest_plugins/filler/filler.py
51 52 53 54 55 56 57 |
|
is_output_stdout(output)
¶
Returns True if the fixture output is configured to be stdout.
Source code in src/pytest_plugins/filler/filler.py
60 61 62 63 64 |
|
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/filler/filler.py
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 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 |
|
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
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 |
|
pytest_report_header(config)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/filler/filler.py
244 245 246 247 248 249 250 |
|
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
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
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
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
pytest_metadata(metadata)
¶
Add or remove metadata to/from the pytest report.
Source code in src/pytest_plugins/filler/filler.py
296 297 298 299 300 |
|
pytest_html_results_table_header(cells)
¶
Customize the table headers of the HTML report table.
Source code in src/pytest_plugins/filler/filler.py
303 304 305 306 307 308 309 |
|
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
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 341 342 343 |
|
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
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 373 374 375 |
|
pytest_html_report_title(report)
¶
Set the HTML report title (pytest-html plugin).
Source code in src/pytest_plugins/filler/filler.py
378 379 380 381 382 |
|
evm_bin(request)
¶
Returns the configured evm tool binary path used to run t8n.
Source code in src/pytest_plugins/filler/filler.py
385 386 387 388 389 390 |
|
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
393 394 395 396 397 398 399 |
|
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/filler/filler.py
402 403 404 405 406 407 408 409 410 411 |
|
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
414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
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
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
base_dump_dir(request)
¶
The base directory to dump the evm debug output.
Source code in src/pytest_plugins/filler/filler.py
456 457 458 459 460 461 462 463 464 |
|
is_output_tarball(request)
¶
Returns True if the output directory is a tarball.
Source code in src/pytest_plugins/filler/filler.py
467 468 469 470 471 472 473 474 475 |
|
output_dir(request, is_output_tarball)
¶
Returns the directory to store the generated test fixtures.
Source code in src/pytest_plugins/filler/filler.py
478 479 480 481 482 483 484 485 486 |
|
output_metadata_dir(output_dir)
¶
Returns the metadata directory to store fixture meta files.
Source code in src/pytest_plugins/filler/filler.py
489 490 491 492 493 494 |
|
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
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 536 537 538 539 540 541 542 |
|
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
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
|
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
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
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
590 591 592 593 594 595 596 597 598 599 600 |
|
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
608 609 610 611 612 613 614 615 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 |
|
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/filler/filler.py
665 666 667 668 669 670 |
|
node_to_test_info(node)
¶
Returns the test info of the current node item.
Source code in src/pytest_plugins/filler/filler.py
673 674 675 676 677 678 679 680 681 682 |
|
fixture_source_url(request)
¶
Returns the URL to the fixture source.
Source code in src/pytest_plugins/filler/filler.py
685 686 687 688 689 690 691 692 693 694 695 696 |
|
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
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 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 |
|
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
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|
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
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 |
|
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 |
|
__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 |
|
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
245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
alloc_mode(request)
¶
Returns the allocation mode for the tests.
Source code in src/pytest_plugins/filler/pre_alloc.py
261 262 263 264 265 266 267 268 |
|
contract_start_address(request)
¶
Returns the starting address for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
271 272 273 274 275 276 |
|
contract_address_increments(request)
¶
Returns the address increment for contract deployment.
Source code in src/pytest_plugins/filler/pre_alloc.py
279 280 281 282 283 284 |
|
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
287 288 289 290 291 292 293 294 295 296 297 |
|
eoa_by_index(i)
cached
¶
Returns an EOA by index.
Source code in src/pytest_plugins/filler/pre_alloc.py
300 301 302 303 304 305 |
|
eoa_iterator()
¶
Returns an iterator over EOAs copies.
Source code in src/pytest_plugins/filler/pre_alloc.py
308 309 310 311 312 313 |
|
evm_code_type(request)
¶
Returns the default EVM code type for all tests (LEGACY).
Source code in src/pytest_plugins/filler/pre_alloc.py
316 317 318 319 320 321 322 323 324 325 |
|
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
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|