From 54a44519eac57edb8272377041696d1f7cbc1a2f Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Wed, 24 Mar 2021 18:10:15 +0100 Subject: [PATCH 1/3] Improve error message when params are undefined --- reframe/core/decorators.py | 6 +++--- reframe/core/meta.py | 10 ++++------ unittests/test_parameters.py | 5 +++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/reframe/core/decorators.py b/reframe/core/decorators.py index 0a0b745430..cbe94d295d 100644 --- a/reframe/core/decorators.py +++ b/reframe/core/decorators.py @@ -84,9 +84,9 @@ def _validate_test(cls): raise ReframeSyntaxError('the decorated class must be a ' 'subclass of RegressionTest') - if (cls.is_abstract()): - raise ValueError(f'decorated test ({cls.__qualname__!r}) is an' - f' abstract test') + if (cls.has_undefined_params()): + raise ValueError(f'decorated test ({cls.__qualname__!r}) has one or ' + f'more undefined parameters') def simple_test(cls): diff --git a/reframe/core/meta.py b/reframe/core/meta.py index 7cc43f6944..09001cd050 100644 --- a/reframe/core/meta.py +++ b/reframe/core/meta.py @@ -232,14 +232,12 @@ def param_space(cls): # Make the parameter space available as read-only return cls._rfm_param_space - def is_abstract(cls): - '''Check if the test is an abstract test. + def has_undefined_params(cls): + '''Check if the test has undefined parameters. - If the parameter space has undefined parameters, the test is considered - an abstract test. If that is the case, the length of the parameter - space is just 0. + If this is the case, the length of the parameter space is just 0. - :return: bool indicating wheteher the test is abstract or not + :return: bool indicating wheteher the test has undefined parameters. :meta private: ''' diff --git a/unittests/test_parameters.py b/unittests/test_parameters.py index e9c1a4fa50..9cb22ef1b4 100644 --- a/unittests/test_parameters.py +++ b/unittests/test_parameters.py @@ -21,6 +21,7 @@ class TwoParams(NoParams): class Abstract(TwoParams): + '''An abstract test is a test with undefined parameters.''' P0 = parameter() @@ -81,14 +82,14 @@ def test_is_abstract_test(): class MyTest(Abstract): pass - assert MyTest.is_abstract() + assert MyTest.has_undefined_params() def test_is_not_abstract_test(): class MyTest(TwoParams): pass - assert not MyTest.is_abstract() + assert not MyTest.has_undefined_params() def test_param_len_is_zero(): From c4be0aa5028e47e4823ee271c7d4b0dc4ae2ab8f Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Thu, 1 Apr 2021 18:48:57 +0200 Subject: [PATCH 2/3] Revert function name to --- reframe/core/decorators.py | 2 +- reframe/core/meta.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/reframe/core/decorators.py b/reframe/core/decorators.py index cbe94d295d..7f1f26f14c 100644 --- a/reframe/core/decorators.py +++ b/reframe/core/decorators.py @@ -84,7 +84,7 @@ def _validate_test(cls): raise ReframeSyntaxError('the decorated class must be a ' 'subclass of RegressionTest') - if (cls.has_undefined_params()): + if (cls.is_abstract()): raise ValueError(f'decorated test ({cls.__qualname__!r}) has one or ' f'more undefined parameters') diff --git a/reframe/core/meta.py b/reframe/core/meta.py index 09001cd050..422997050a 100644 --- a/reframe/core/meta.py +++ b/reframe/core/meta.py @@ -232,10 +232,11 @@ def param_space(cls): # Make the parameter space available as read-only return cls._rfm_param_space - def has_undefined_params(cls): - '''Check if the test has undefined parameters. + def is_abstract(cls): + '''Check if the class is an abstract test. - If this is the case, the length of the parameter space is just 0. + This is the case when some parameters are undefined, which results in + the length of the parameter space being 0. :return: bool indicating wheteher the test has undefined parameters. From 694113988b1da607e8dd8bbcd1ef2af96970c78a Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Fri, 2 Apr 2021 10:27:50 +0200 Subject: [PATCH 3/3] Update unit tests --- unittests/test_parameters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/test_parameters.py b/unittests/test_parameters.py index 9cb22ef1b4..f1605ff9c4 100644 --- a/unittests/test_parameters.py +++ b/unittests/test_parameters.py @@ -82,14 +82,14 @@ def test_is_abstract_test(): class MyTest(Abstract): pass - assert MyTest.has_undefined_params() + assert MyTest.is_abstract() def test_is_not_abstract_test(): class MyTest(TwoParams): pass - assert not MyTest.has_undefined_params() + assert not MyTest.is_abstract() def test_param_len_is_zero():