Skip to content

[feat] Support relative imports in tests #3110

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

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

vkarak
Copy link
Contributor

@vkarak vkarak commented Feb 7, 2024

Relative imports in tests are currently supported only for tests inside the reframe's installation prefix. This is problematic for custom utilities and libraries that users may want to use in their tests.

To enable relative imports in tests loaded by reframe, the parent directory of the test must contain a __init__.py file.

I've updated the structure of the existing test library in the unit tests to expose the limitation of the current implementation and added a unit test that reproduces it.

Closes #3076.

@vkarak vkarak added this to the ReFrame 4.6 milestone Feb 7, 2024
@vkarak vkarak requested review from ekouts, victorusu and teojgo February 7, 2024 14:18
@vkarak vkarak self-assigned this Feb 7, 2024
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f2a2326) 86.64% compared to head (0662303) 86.64%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3110   +/-   ##
========================================
  Coverage    86.64%   86.64%           
========================================
  Files           61       61           
  Lines        12046    12051    +5     
========================================
+ Hits         10437    10442    +5     
  Misses        1609     1609           

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

@vkarak vkarak merged commit ead9f84 into reframe-hpc:develop Feb 8, 2024
@vkarak vkarak deleted the feat/test-relative-imports branch February 8, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Import error when loading a test with a relative import
3 participants