-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest Migrating Python Tests to pytest
in Favor of Current tests/test_all.py
#2944
Comments
About MotivationTest ParallelizationFor test parallelization, there are several distinct scenarios:
For the third scenario, implementing thread pools within the current framework could be a simpler alternative to a complete framework migration. While I've only encountered the first two scenarios once in my experience, we should further discuss specific implementation approaches if these use cases are relevant to your needs. Current Framework Usability for Debugging Single TestsI think the current framework is reasonably accessible: since individual tests can be run via RecommendationLet's evaluate pytest migration necessity based on specific testing requirements. If needed, we could start with migrating RPC and VM layer tests first. About Implementation ConsiderationsBeyond invoking the test scripts, So before considering migration, we should thoroughly review the logic flow from the main function of |
I would first explain for what ScenariosDifferent Node Setup Parameters
pytest's Fresh Environment Requirements
pytest's fixture scope is designed for this scenerio. @pytest.fixture(scope="function")
def new_env() -> ConfluxTestFramework:
...... # set up env
def test_CIP_123(new_env: ConfluxTestFramework):
w3 = Web3(new_env.url)
......
def test_CIP_456(new_env: ConfluxTestFramework):
w3 = Web3(new_env.url)
...... Same-Node Parallelization
This would be something tricky. But I would first know the reason of the the situation setting.
test index assignmentI think this suggests the slow_tests
port allocationWithin each test, the worker_id can be got from fixture(https://pytest-xdist.readthedocs.io/en/stable/how-to.html#identifying-the-worker-process-during-a-test). And it can be used to allocate port
NecessityFrom my end, I think the "necessity" in migratioin can be better described as whether the cost of migration is worth the convenience I think it is hard to tell the answer before actual coding. And several local changes and I found the migration may be somewhat easier than I expected. I think I can first create a PR based on several RPC tests, based on which we can better judge whether it is necessary for migration |
I believe
I want to discuss what kind of parallel requirements cannot be met by existing frameworks but can be satisfied by pytest. Furthermore, I'm against code migration without clear motivation. For test code, there are currently several more valuable things worth doing:
|
Sorry for that I didn't express myself clearly. Overall I think there is not such a scenario which pytest can do but current test framework cannot. The aim of the migration is convenience of easier test setup and simpler development.
I want to convey that, in a single TestClass, there might be many test cases, just like most tests under the I agree the listed other 2 issues are of higher priority, and I can help resolving the mentioned 2 issues. Regarding the test framework, I would not insisit on migrating to |
Why
There is some disadvantages for current test framework, for example
The above disadvantages can be resolved by the pytest framework, and popular ides such as vs code already provided gui so debugging or a group of tests can be run with convinenience.
It would also bring convience as we can make use of pytest fixture or plugins to simplify the development
How this can be done
Create a new folder such as
tests_new
and the migrated tests will be placed intests_new
folder. With every test migrated, it will be removed fromtests
folder. During the migration, both tests intests
andtests_all
will be executed. In this manner, the changes are easy to be reviewed and won't affect existing tests or pending pull requests.Implementation details
pytest
pluginpytest-xdist
(parallel) andpytest-order
(test order) will be adopted to implement the features done bytest_all.py
ConfluxTestFramework
will be refactored, themain()
function will be tear down andrun_test
will be removed. It will not be directly used as parent class of TestClass but still be used to setup the environment.The text was updated successfully, but these errors were encountered: