Skip to content

Commit

Permalink
make RoseStemVersionException print the correct missing variable (#252)
Browse files Browse the repository at this point in the history
* make RoseStemVersionException print the correct missing variable

* fix broken tests
  • Loading branch information
wxtim authored Aug 29, 2023
1 parent 92df362 commit af64213
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cylc/rose/stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,17 @@ def __repr__(self):
__str__ = __repr__


class RoseStemVersionException(Exception):
class RoseStemVersionException(CylcError):

"""Exception class when running the wrong rose-stem version."""

def __init__(self, version):

Exception.__init__(self, version)
if version is None:
self.suite_version = (
"does not have ROSE_VERSION set in the rose-suite.conf"
"does not have ROSE_STEM_VERSION set in the "
"rose-suite.conf"
)
else:
self.suite_version = "at version %s" % (version)
Expand All @@ -165,7 +167,7 @@ def __repr__(self):
__str__ = __repr__


class RoseSuiteConfNotFoundException(Exception):
class RoseSuiteConfNotFoundException(CylcError):

"""Exception class when unable to find rose-suite.conf."""

Expand Down
5 changes: 3 additions & 2 deletions tests/functional/test_rose_stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def test_with_config2(self, with_config2, expected):
assert expected in with_config2['jobout_content']


def test_incompatible_versions(setup_stem_repo, monkeymodule):
def test_incompatible_versions(setup_stem_repo, monkeymodule, caplog, capsys):
"""It fails if trying to install an incompatible version.
"""
# Copy suite into working copy.
Expand All @@ -587,7 +587,8 @@ def test_incompatible_versions(setup_stem_repo, monkeymodule):
str(setup_stem_repo['workingcopy']),
"fcm:foo.x_tr@head",
],
'workflow_name': str(setup_stem_repo['suitename'])
'workflow_name': str(setup_stem_repo['suitename']),
'verbosity': 2,
}

monkeymodule.setattr('sys.argv', ['stem'])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_rose_stem_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test__check_suite_version_incompatible(get_StemRunner, tmp_path):
stemrunner = get_StemRunner(
{}, {'stem_sources': [], 'workflow_conf_dir': str(tmp_path)})
with pytest.raises(
RoseStemVersionException, match='ROSE_VERSION'
RoseStemVersionException, match='ROSE_STEM_VERSION'
):
stemrunner._check_suite_version(str(tmp_path / 'rose-suite.conf'))

Expand Down

0 comments on commit af64213

Please sign in to comment.