Skip to content

Add more pytest fixture tests #6882

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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

danielhollas
Copy link
Collaborator

@danielhollas danielhollas commented May 20, 2025

Follow-up to #6904

Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.31%. Comparing base (b235b3a) to head (98ce975).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6882      +/-   ##
==========================================
+ Coverage   79.20%   79.31%   +0.12%     
==========================================
  Files         566      566              
  Lines       43461    43461              
==========================================
+ Hits        34417    34468      +51     
+ Misses       9044     8993      -51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielhollas
Copy link
Collaborator Author

@agoscinski just heads up that I think this should be included in the 2.7.0 release otherwise we risk breaking people's CIs (as it broke aiidalab-widgets-base). I can work on this over the weekend to drive it home.

@danielhollas danielhollas force-pushed the fix-legacy-fixtures branch from 6db7e2d to c34f72e Compare May 26, 2025 23:06
@danielhollas danielhollas changed the title WIP: Fix legacy pytest fixtures Fix legacy pytest fixtures May 27, 2025
@agoscinski
Copy link
Contributor

@danielhollas what do you think about restructuring the tests into tests/unittests and tests/fixtures, where tests/unittests contains all current tests and tests/fixtures contains all tests you include by this PR for the fixture. Then we can execute these folder separately quite conveniently in the CI without entanglement, we have all tests in the test folder. I am bit worried about tests in the src that some discovery will run these tests by accident in some setups for whatever reason. I have no good argument that this could happen but I recently had the problem that when activating a spack environment that pytest always ran in any folder the spack pytest tests. So I would like to avoid shipping tests to the user

@danielhollas
Copy link
Collaborator Author

@agoscinski I agree that we should not ship a test file as part of the package. However, splitting the test suite at the top like that seems like a very heavy-handed solution to this. Ultimately we just need to move one test file out of the src/ directory somewhere else. I'll think about it a bit more, resolve the merge conflicts here and ask for review once it is ready.

@danielhollas danielhollas force-pushed the fix-legacy-fixtures branch from 9329183 to e5adde7 Compare June 12, 2025 13:11
@danielhollas danielhollas force-pushed the fix-legacy-fixtures branch from a692148 to dab0af6 Compare June 12, 2025 13:22
@danielhollas danielhollas changed the title Fix legacy pytest fixtures Add more pytest fixture tests Jun 12, 2025
@danielhollas danielhollas marked this pull request as ready for review June 12, 2025 13:23
@danielhollas danielhollas requested a review from agoscinski June 12, 2025 13:24
@danielhollas
Copy link
Collaborator Author

For now I've moved the test file inside the .github directory. Given that this file shouldn't really be updated often this is hopefully fine. @agoscinski feel free to take over this PR, I will not have time to work on this further in the next two weeks.

from aiida.orm import Computer
from aiida.transports import AsyncTransport, BlockingTransport
from aiida.transports.plugins import _AsyncSSH, _OpenSSH


def test_profile_config():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is already covered in tests/tools/pytest_fixtures/test_configuration.py so I removed it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this file was basically just moved from tests/manage/tests/test_pytest_fixtures.py to tests/tools/pytest_fixtures/test_orm.py. And since the tests here work for both old and new fixtured, I've also copied the to the .github/test_legacy_pytest_fixtures.py.

@danielhollas
Copy link
Collaborator Author

@agoscinski I've merged in main so this is ready for review. The diff on Github might be a bit confusing, please see my comments.

@danielhollas danielhollas requested a review from mbercx July 23, 2025 14:29
pytest_plugins = ['aiida.manage.tests.pytest_fixtures']


def test_aiida_config(tmp_path_factory):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were copied here from tests/manage/tests/test_pytest_fixtures.py, they are valid for both the legacy and new fixtures.

@mbercx
Copy link
Member

mbercx commented Jul 24, 2025

I see you've picked up I'm looking into the aiida-core test fixtures ^^. Valiant effort @danielhollas, thanks a lot. I'll try to review it this week, but have some other TODO's to check before I can get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants