Skip to content

Commit

Permalink
Tests: Catch warning in restart_mode test for PwBaseWorkChain
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbercx authored May 25, 2023
1 parent 0702152 commit 45e1907
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/aiida_quantumespresso/calculations/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def validate_inputs(cls, value, port_namespace):
parameters.get('ELECTRONS', {}).get('startingwfc', None) == 'file'
]):
warnings.warn(
f'`parent_folder` input was provided for the `{calculation_type}` `PwCalculation`, but no input'
f'`parent_folder` input was provided for the `{calculation_type}` `PwCalculation`, but no input '
'parameters were provided to restart from this folder.\n\n'
'Please set one of the following in the input parameters:\n'
" parameters['CONTROL']['restart_mode'] = 'restart'\n"
Expand Down
7 changes: 6 additions & 1 deletion tests/workflows/pw/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,12 @@ def test_restart_mode(generate_workchain_pw, generate_calc_job_node, restart_mod
inputs['pw']['parent_folder'] = node.outputs.remote_folder
inputs['pw']['parameters'] = Dict({'CONTROL': {'restart_mode': restart_mode}})

process = generate_workchain_pw(inputs=inputs)
if restart_mode == 'restart':
process = generate_workchain_pw(inputs=inputs)
else:
with pytest.warns(UserWarning, match='but no input parameters were'):
process = generate_workchain_pw(inputs=inputs)

process.setup()

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

0 comments on commit 45e1907

Please sign in to comment.