Skip to content

Better support custom imports from user tests #2595

@vkarak

Description

@vkarak

This is a recurring issue. If a user tests needs to import a custom module (e.g., other tests or user libraries), ReFrame will not automatically import those. The user has to set programmatically set the python path to allow reframe to load the modules. This happens only if the user tests reside outside the reframe installation prefix. Here is an example to reproduce:

dir/
├── user_imports.py
└── userlib
    └──__init__.py

And the user_imports.py is the following:

import reframe as rfm

# Uncomment the following lines for the example to work.
# import os
# import sys
# sys.path.append(os.path.dirname(__file__))
from userlib import SYMBOL  # noqa: F501


@rfm.simple_test
class echo_test(rfm.RunOnlyRegressionTest):
    executable = 'echo hello'
    valid_systems = ['*']
    valid_prog_environs = ['*']

    @sanity_function
    def validate(self):
        return True

The userlib module's contents are:

SYMBOL = 1

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions