Skip to content

Class inheritance #2112

@yellowhat

Description

@yellowhat

Hi,
I would like to create a class that inherit from CompileOnlyRegressionTest to create a sort of template class:

import reframe as rfm
import reframe.utility.sanity as sn
from reframe.core.decorators import run_before
from typing import List


@rfm.simple_test
class Build(rfm.CompileOnlyRegressionTest):
    valid_prog_environs = ["*"]
    build_system = "Spack"
    specs = List[str]

    @run_before("compile")
    def setup_build_system(self):
        self.build_system.specs = self.specs
        self.build_system.install_tree = "$SPACK_ROOT/opt/spack"

    @run_before("sanity")
    def set_sanity_patterns(self):
        self.sanity_patterns = sn.assert_found("Updating", self.stdout)


@rfm.simple_test
class FIOBuildTest(Build):
    descr = "FIO Build"
    valid_systems = ["hpc:local"]
    specs = ["fio"]

But I get:

Validating '/home/user/inherit.py': OK
./reframe/bin/reframe: skipping test file '/home/user/hpc/inherit.py': attribute error: ../../../usr/lib64/python3.8/typing.py:760: __name__
        raise AttributeError(attr)
 (rerun with '-v' for more information)
Traceback (most recent call last):
  File "/home/user/reframe/reframe/frontend/loader.py", line 172, in load_from_file
    util.import_module_from_file(filename, force)
  File "/home/user/reframe/reframe/utility/__init__.py", line 89, in import_module_from_file
    return _do_import_module_from_file(filename, module_name)
  File "/home/user/reframe/reframe/utility/__init__.py", line 66, in _do_import_module_from_file
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/hpc/inherit.py", line 11, in <module>
    class Build(rfm.CompileOnlyRegressionTest):
  File "/home/user/reframe/reframe/core/meta.py", line 317, in __init__
    if callable(v) and v.__name__ in b._final_methods:
  File "/usr/lib64/python3.8/typing.py", line 760, in __getattr__
    raise AttributeError(attr)
AttributeError: __name__

Any suggestions?

Thanks

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions