Skip to content

Commit 45e1907

Browse files
authored
Tests: Catch warning in restart_mode test for PwBaseWorkChain
The `test_restart_mode` test was raising a warning related to the presence of the `parent_folder` input for `restart_mode = restart` (which is expected). Here the test is adapted to catch the warning for this this input and make sure the message is correct.
1 parent 0702152 commit 45e1907

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/aiida_quantumespresso/calculations/pw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def validate_inputs(cls, value, port_namespace):
208208
parameters.get('ELECTRONS', {}).get('startingwfc', None) == 'file'
209209
]):
210210
warnings.warn(
211-
f'`parent_folder` input was provided for the `{calculation_type}` `PwCalculation`, but no input'
211+
f'`parent_folder` input was provided for the `{calculation_type}` `PwCalculation`, but no input '
212212
'parameters were provided to restart from this folder.\n\n'
213213
'Please set one of the following in the input parameters:\n'
214214
" parameters['CONTROL']['restart_mode'] = 'restart'\n"

tests/workflows/pw/test_base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,12 @@ def test_restart_mode(generate_workchain_pw, generate_calc_job_node, restart_mod
312312
inputs['pw']['parent_folder'] = node.outputs.remote_folder
313313
inputs['pw']['parameters'] = Dict({'CONTROL': {'restart_mode': restart_mode}})
314314

315-
process = generate_workchain_pw(inputs=inputs)
315+
if restart_mode == 'restart':
316+
process = generate_workchain_pw(inputs=inputs)
317+
else:
318+
with pytest.warns(UserWarning, match='but no input parameters were'):
319+
process = generate_workchain_pw(inputs=inputs)
320+
316321
process.setup()
317322

318323
assert process.ctx.inputs['parameters']['CONTROL']['restart_mode'] == expected

0 commit comments

Comments
 (0)