16
16
simulated_solution ,
17
17
)
18
18
from message_ix_models .report import prepare_reporter , sim
19
- from message_ix_models .testing import GHA
20
19
from message_ix_models .util ._logging import silence_log
21
20
22
21
if TYPE_CHECKING :
26
25
log = logging .getLogger (__name__ )
27
26
28
27
28
+ @pytest .fixture
29
+ def quiet_genno (caplog ):
30
+ """Quiet some log messages from genno via by :func:`.reporting.prepare_reporter`."""
31
+ caplog .set_level (logging .WARNING , logger = "genno.config" )
32
+ caplog .set_level (logging .WARNING , logger = "genno.compat.pyam" )
33
+
34
+
29
35
@pytest .mark .xfail (
30
36
reason = "Requires variables in .report.legacy.default_tables that have not been "
31
37
"migrated from message_data"
@@ -110,6 +116,7 @@ def test_debug(
110
116
del tmp
111
117
112
118
119
+ @MARK [10 ]
113
120
@MARK [7 ]
114
121
@build .get_computer .minimum_version
115
122
@pytest .mark .parametrize (
@@ -121,7 +128,7 @@ def test_debug(
121
128
param ("ISR" , "A" , marks = MARK [3 ]),
122
129
),
123
130
)
124
- def test_report_bare_solved (request , test_context , tmp_path , regions , years ):
131
+ def test_bare (request , test_context , tmp_path , regions , years ):
125
132
"""Run MESSAGEix-Transport–specific reporting."""
126
133
from message_ix_models .model .transport .report import callback
127
134
from message_ix_models .report import Config
@@ -153,13 +160,6 @@ def test_report_bare_solved(request, test_context, tmp_path, regions, years):
153
160
rep .get (key )
154
161
155
162
156
- @pytest .fixture
157
- def quiet_genno (caplog ):
158
- """Quiet some log messages from genno via by :func:`.reporting.prepare_reporter`."""
159
- caplog .set_level (logging .WARNING , logger = "genno.config" )
160
- caplog .set_level (logging .WARNING , logger = "genno.compat.pyam" )
161
-
162
-
163
163
@build .get_computer .minimum_version
164
164
@MARK [10 ]
165
165
@MARK [7 ]
@@ -171,7 +171,7 @@ def quiet_genno(caplog):
171
171
False , # Use data from an Excel export
172
172
),
173
173
)
174
- def test_simulated_solution (request , test_context , build , regions = "R12" , years = "B" ):
174
+ def test_simulated (request , test_context , build , regions = "R12" , years = "B" ):
175
175
""":func:`message_ix_models.report.prepare_reporter` works on the simulated data."""
176
176
test_context .update (regions = regions , years = years )
177
177
rep = simulated_solution (request , test_context , build )
@@ -200,35 +200,9 @@ def test_simulated_solution(request, test_context, build, regions="R12", years="
200
200
assert p .joinpath ("DF_POPULATION_IN.xml" ).exists ()
201
201
202
202
203
- @build .get_computer .minimum_version
204
- @mark .usefixtures ("quiet_genno" )
205
- @pytest .mark .parametrize (
206
- "plot_name" ,
207
- # # All plots
208
- # list(PLOTS.keys()),
209
- # Only a subset
210
- [
211
- # "energy-by-cmdty",
212
- "stock-ldv" ,
213
- # "stock-non-ldv",
214
- ],
215
- )
216
- def test_plot_simulated (request , test_context , plot_name , regions = "R12" , years = "B" ):
217
- """Plots are generated correctly using simulated data."""
218
- test_context .update (regions = regions , years = years )
219
- log .debug (f"test_plot_simulated: { test_context .regions = } " )
220
- rep = simulated_solution (request , test_context , build = True )
221
-
222
- # print(rep.describe(f"plot {plot_name}")) # DEBUG
223
-
224
- # Succeeds
225
- rep .get (f"plot { plot_name } " )
226
-
227
-
228
- @pytest .mark .xfail (condition = GHA , reason = "Temporary, for #213; fails on GitHub Actions" )
229
203
@sim .to_simulate .minimum_version
230
204
@MARK [10 ]
231
- def test_iamc_simulated (
205
+ def test_simulated_iamc (
232
206
request , tmp_path_factory , test_context , regions = "R12" , years = "B"
233
207
) -> None :
234
208
test_context .update (regions = regions , years = years )
@@ -273,3 +247,29 @@ def test_iamc_simulated(
273
247
} <= set (ts ["variable" ].unique ())
274
248
275
249
del result
250
+
251
+
252
+ @build .get_computer .minimum_version
253
+ @MARK [10 ]
254
+ @mark .usefixtures ("quiet_genno" )
255
+ @pytest .mark .parametrize (
256
+ "plot_name" ,
257
+ # # All plots
258
+ # list(PLOTS.keys()),
259
+ # Only a subset
260
+ [
261
+ # "energy-by-cmdty",
262
+ "stock-ldv" ,
263
+ # "stock-non-ldv",
264
+ ],
265
+ )
266
+ def test_simulated_plot (request , test_context , plot_name , regions = "R12" , years = "B" ):
267
+ """Plots are generated correctly using simulated data."""
268
+ test_context .update (regions = regions , years = years )
269
+ log .debug (f"test_plot_simulated: { test_context .regions = } " )
270
+ rep = simulated_solution (request , test_context , build = True )
271
+
272
+ # print(rep.describe(f"plot {plot_name}")) # DEBUG
273
+
274
+ # Succeeds
275
+ rep .get (f"plot { plot_name } " )
0 commit comments