-
Notifications
You must be signed in to change notification settings - Fork 15
Replace @pytest.mark.order with fixtures and finalizers for E2E tests #370
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jacalata <[email protected]>
Co-authored-by: jacalata <[email protected]>
|
||
# Cleanup | ||
try: | ||
delete_project(parent_location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you delete the default project you do not need to also delete the child projects
|
||
@pytest.mark.order(5) | ||
def test_users_remove_from_group(self): | ||
def test_users_remove_from_group(self, test_group): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need ordered tests because e.g. this test must take place after test_users_add_to_group
|
||
@pytest.mark.order(10) | ||
def test_wb_publish(self): | ||
def test_wb_publish(self, test_projects): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the publishing test must be run after projects are created but before any get tests
|
||
@pytest.mark.order(19) | ||
def test_wb_delete(self): | ||
def test_wb_delete(self, test_projects): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wb_delete and ds_delete must run after the get, extract and export tests
suggestion from Andy: Consider also adding a "before all" setup step that deletes all workbooks and datasources that exist on the site that match the "publishable" name pattern. Currently if you stopped the tests mid-way through execution, they'd never get deleted. |
Summary
Refactored E2E tests to use pytest fixtures with finalizers instead of
@pytest.mark.order
decorators, addressing the issue raised in #366 about managing test order numbers manually.Problem
The E2E test suites (
online_tests.py
andlanguage_tests.py
) were using@pytest.mark.order
decorators with numeric values (1-21) to control test execution order. This approach had several limitations:pytest-order
dependencySolution
Replaced explicit ordering with pytest fixtures that handle setup and teardown automatically:
Fixtures Created (with finalizers for cleanup)
online_tests.py:
login_session()
- Auto-runs before all testssite_users(login_session)
- Creates/deletes test userstest_group(site_users)
- Creates/deletes test grouptest_projects(login_session)
- Creates/deletes test projectslanguage_tests.py:
login_all_languages()
- Tests login in all languagessite_users(login_all_languages)
- Creates/deletes test userstest_group(site_users)
- Creates/deletes test grouptest_projects(login_all_languages)
- Creates/deletes test projectsExample Conversion
Before:
After:
Changes
@pytest.mark.order
decoratorspytest-order
dependency frompyproject.toml
Benefits
Testing
Fixes #366
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.