Skip to content

Commit

Permalink
Update tests for #213
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Aug 20, 2024
1 parent 725eba5 commit c1c5077
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
6 changes: 2 additions & 4 deletions message_ix_models/model/transport/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

log = logging.getLogger(__name__)

# Common marks for transport code
# Common marks for transport code. Do not reuse keys that are less than the highest key
# appearing in the dict.
MARK = {
0: pytest.mark.xfail(
reason="Missing R14 input data/assumptions", raises=FileNotFoundError
Expand All @@ -41,9 +42,6 @@
5: lambda f: pytest.mark.xfail(
raises=FileNotFoundError, reason=f"Requires non-public data ({f})"
),
6: pytest.mark.xfail(
reason="Temporary, for https://github.com/iiasa/message-ix-models/pull/207"
),
7: pytest.mark.xfail(
condition=testing.GHA and platform.system() == "Darwin" and not HAS_GRAPHVIZ,
reason="Graphviz missing on macos-13 GitHub Actions runners",
Expand Down
5 changes: 4 additions & 1 deletion message_ix_models/tests/model/transport/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_build_existing(tmp_path, test_context, url, solve=False):
],
)
def test_debug(test_context, tmp_path, regions, years, N_node, options):
"""Exogenous demand calculation succeeds."""
"""Debug particular calculations in the transport build process."""
c, info = configure_build(
test_context, tmp_path=tmp_path, regions=regions, years=years, options=options
)
Expand All @@ -184,6 +184,9 @@ def test_debug(test_context, tmp_path, regions, years, N_node, options):
# ("constraints::ixmp+transport+non-ldv", None),
# ("energy:flow-n-product:trn other+1", "TJ"),
# ("transport other::ixmp", None),
# ("sales fraction:n-t-y:ldv", None),
# ("load factor ldv:n-y", None),
# ("ldv hnc::ixmp", None),
):
print(f"\n\n-- {key} --\n\n")
print(c.describe(key))
Expand Down
3 changes: 1 addition & 2 deletions message_ix_models/tests/model/transport/test_disutility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from message_ix_models.model.transport import testing


@testing.MARK[6]
def test_disutility(
caplog, tmp_path, test_context, regions="R12", years="B", options={}
):
Expand Down Expand Up @@ -32,4 +31,4 @@ def test_disutility(
# Data are added to the scenario
N = 12 * 27 * 12 * 14 # n × cg × t × y
with assert_logs(caplog, f"{N} rows in 'input'"):
c.get("add message_data.model.transport.disutility")
c.get("add message_ix_models.model.transport.disutility")
15 changes: 6 additions & 9 deletions message_ix_models/tests/model/transport/test_report.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logging
from copy import deepcopy
from importlib.metadata import version
from typing import TYPE_CHECKING

import genno
import pytest
from packaging.version import parse
from pytest import mark, param

from message_ix_models import ScenarioInfo
Expand All @@ -24,7 +22,6 @@
log = logging.getLogger(__name__)


@MARK[6]
def test_configure_legacy():
from message_ix_models.report.legacy.default_tables import TECHS

Expand Down Expand Up @@ -57,7 +54,7 @@ def test_configure_legacy():
@pytest.mark.parametrize(
"regions, years",
(
param("R11", "A", marks=MARK[1]),
param("R11", "A", marks=MARK[2](ValueError)),
("R12", "A"),
param("R14", "A", marks=MARK[2](genno.ComputationError)),
param("ISR", "A", marks=MARK[3]),
Expand Down Expand Up @@ -150,11 +147,11 @@ def test_plot_simulated(request, test_context, plot_name, regions="R12", years="


@sim.to_simulate.minimum_version
@pytest.mark.xfail(
raises=AssertionError,
reason="Temporary, for #549",
condition=parse(version("message_ix")) >= parse("3.8.0"),
)
# @pytest.mark.xfail(
# raises=AssertionError,
# reason="Temporary, for #549",
# condition=parse(version("message_ix")) >= parse("3.8.0"),
# )
@pytest.mark.usefixtures("preserve_report_callbacks")
def test_iamc_simulated(
request, tmp_path_factory, test_context, regions="R12", years="B"
Expand Down

0 comments on commit c1c5077

Please sign in to comment.