Skip to content

Commit

Permalink
Adjust two tests for more informative exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Nov 19, 2024
1 parent 250dea6 commit 0d3ad85
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
10 changes: 2 additions & 8 deletions ixmp/tests/core/test_scenario.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import sys
from pathlib import Path
from shutil import copyfile

Expand Down Expand Up @@ -98,13 +97,8 @@ def test_from_url(self, mp, caplog):

# Giving an invalid scenario with errors='warn' causes a message to be logged
msg = (
"ValueError: "
+ (
"scenario='Hitchhikerfoo'"
if sys.version_info.minor != 12
else "model, scenario, or version not found"
)
+ f"\nwhen loading Scenario from url: {repr(url + 'foo')}"
"ValueError: scenario='Hitchhikerfoo'\n"
f"when loading Scenario from url: {repr(url + 'foo')}"
)
with assert_logs(caplog, msg):
scen, mp = ixmp.Scenario.from_url(url + "foo")
Expand Down
8 changes: 1 addition & 7 deletions ixmp/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import sys
from pathlib import Path

import pandas as pd
Expand Down Expand Up @@ -422,12 +421,7 @@ def test_solve(ixmp_cli, test_mp):
]
result = ixmp_cli.invoke(cmd)
assert result.exit_code == 1, result.output
exp = (
"='non-existing'"
if sys.version_info.minor != 12
else ", scenario, or version not found"
)
assert f"Error: model{exp}" in result.output
assert "Error: model='non-existing'" in result.output

result = ixmp_cli.invoke([f"--url=ixmp://{test_mp.name}/foo/bar", "solve"])
assert UsageError.exit_code == result.exit_code, result.output
Expand Down

0 comments on commit 0d3ad85

Please sign in to comment.