refactor(fixtures,consume): Make BaseFixture
able to parse any format
#1210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🗒️ Description
BaseFixture
RefactorRefactors
BaseFixture
to make it able to parse (validate) any defined fixture format.The class now automatically collects all fixture formats and generates a type adapter that is able to discriminate based on the
_info.fixture_format
field.This allows the creation of a single
Fixtures
class that is a pydantic root model, and is able to parse any fixtures file, without the need to create a new class for each fixture type, and the following classes have been removed:The constants
FIXTURE_FORMATS
andEXECUTE_FORMATS
have also been removed since they are now automatically generated for current and any future fixture formats without any extra code.One caveat is that
ethereum/tests
cannot be parsed automatically since they lack the_info.fixture_format
field.Due to this, a single definition of
BlockchainFixtures
is added tosrc/cli/eofwrap.py
, since this script loads legacy tests.Consume Fixture Loading Refactor
All hive consume simulators new use a single generic
fixture
to load any type of fixture, and the pytest fixturefixture_format
has been added to every parametrized case.New Fixture Format Example
In #1175, a new fixture format is introduced on top of the changes in this branch, and it can be appreciated how much the changes in this PR simplify the fixture format creation.
🔗 Related Issues
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.