|
6 | 6 | import pytest |
7 | 7 | from aiida.common.datastructures import CodeInfo |
8 | 8 | from aiida.engine import run_get_node |
9 | | -from aiida.orm import Data, Float, FolderData, Int, List, RemoteData, SinglefileData, Str |
| 9 | +from aiida.orm import Data, Float, FolderData, Int, List, Log, RemoteData, SinglefileData, Str |
10 | 10 |
|
11 | 11 | from aiida_shell.calculations.shell import ShellJob |
12 | 12 | from aiida_shell.data import EntryPointData, PickledData |
@@ -453,7 +453,7 @@ def parser(dirpath): |
453 | 453 | assert node.outputs.string == value |
454 | 454 |
|
455 | 455 |
|
456 | | -def test_input_output_filename_overlap(generate_calc_job, generate_code, tmp_path, caplog): |
| 456 | +def test_input_output_filename_overlap(generate_calc_job, generate_code, tmp_path): |
457 | 457 | """Test functionality when input and output filenames overlap.""" |
458 | 458 | code = generate_code() |
459 | 459 |
|
@@ -481,18 +481,22 @@ def test_input_output_filename_overlap(generate_calc_job, generate_code, tmp_pat |
481 | 481 |
|
482 | 482 | # If the filename clash is due to an "implicit" filename, instead of raising, the filename of the node should be |
483 | 483 | # automatically made unique and a warning logged to make the user aware. |
484 | | - dirpath, calc_info = generate_calc_job( |
485 | | - 'core.shell', |
486 | | - inputs={ |
| 484 | + def generate_inputs(): |
| 485 | + return { |
487 | 486 | 'code': code, |
488 | 487 | 'nodes': {'file': SinglefileData.from_string('content', filename='stdout')}, |
489 | | - }, |
490 | | - ) |
| 488 | + } |
| 489 | + |
| 490 | + dirpath, calc_info = generate_calc_job('core.shell', inputs=generate_inputs()) |
| 491 | + process = generate_calc_job('core.shell', inputs=generate_inputs(), return_process=True) |
| 492 | + |
491 | 493 | code_info = calc_info.codes_info[0] |
492 | 494 | filenames = [p.name for p in dirpath.iterdir()] |
493 | 495 | assert code_info.stdout_name not in filenames |
494 | 496 | assert code_info.stderr_name not in filenames |
495 | | - assert 'filename `stdout` for node `file` overlaps' in caplog.records[0].message |
| 497 | + |
| 498 | + message = 'filename `stdout` for node `file` overlaps' |
| 499 | + assert any(message in entry.message for entry in Log.collection.get_logs_for(process.node)) |
496 | 500 |
|
497 | 501 | # If the contents of a ``FolderData`` overlap with a reserved filename, an exception is raised. This is done because |
498 | 502 | # not doing everything will most likely fail the calculation as some input files will be overwritten. The plugin can |
|
0 commit comments