Skip to content
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

make RoseStemVersionException print the correct missing variable #252

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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