From 352cd7b9af15f8887ad4a78a95a2e6130a25a897 Mon Sep 17 00:00:00 2001 From: Fridolin Glatter Date: Tue, 19 Nov 2024 08:34:39 +0100 Subject: [PATCH] Adjust two tests for more informative exceptions --- ixmp/tests/core/test_scenario.py | 10 ++-------- ixmp/tests/test_cli.py | 8 +------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/ixmp/tests/core/test_scenario.py b/ixmp/tests/core/test_scenario.py index 6259066fb..3592280f0 100644 --- a/ixmp/tests/core/test_scenario.py +++ b/ixmp/tests/core/test_scenario.py @@ -1,5 +1,4 @@ import re -import sys from pathlib import Path from shutil import copyfile @@ -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") diff --git a/ixmp/tests/test_cli.py b/ixmp/tests/test_cli.py index 15c66db1d..982414319 100644 --- a/ixmp/tests/test_cli.py +++ b/ixmp/tests/test_cli.py @@ -1,5 +1,4 @@ import re -import sys from pathlib import Path import pandas as pd @@ -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