From c13b7b85108b598f934d486b005c50da7588a198 Mon Sep 17 00:00:00 2001 From: Julian Geiger Date: Tue, 19 Aug 2025 12:02:22 +0200 Subject: [PATCH 1/2] ArithmeticAdd dump folder --- tests/cmdline/commands/test_process.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cmdline/commands/test_process.py b/tests/cmdline/commands/test_process.py index b4686e07a0..b9394ae483 100644 --- a/tests/cmdline/commands/test_process.py +++ b/tests/cmdline/commands/test_process.py @@ -687,11 +687,12 @@ def test_dump_specified_path_message(self, run_cli_command, tmp_path, generate_c assert result.exception is None, result.output assert f'Using specified output path: `{test_path}`' in result.output - def test_dump_warning_message_displayed(self, run_cli_command, generate_calculation_node_add): + def test_dump_warning_message_displayed(self, run_cli_command, tmp_path, generate_calculation_node_add): """Test that warning message about new feature is displayed""" + test_path = tmp_path / 'specified-path' node = generate_calculation_node_add() - options = [str(node.pk)] + options = [str(node.pk), '--path', str(test_path)] result = run_cli_command(cmd_process.process_dump, options) assert result.exception is None, result.output assert 'This is a new feature which is still in its testing phase' in result.output From e893486a8d92c3194290b3fcb1ae91f5f6dcf037 Mon Sep 17 00:00:00 2001 From: Julian Geiger Date: Thu, 21 Aug 2025 09:55:47 +0200 Subject: [PATCH 2/2] Hack: Run `test_data_exporters` in tmp_dir Fixing it properly, e.g., by adding a `target_dir` parameter, would require adding it throughout the call stack (`_export_yaml`, `Data.export`, `Data._exportcontent`, `data_export`). Maybe do later on. --- tests/orm/nodes/data/test_data.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/orm/nodes/data/test_data.py b/tests/orm/nodes/data/test_data.py index 7714ed713a..b16bd535cd 100644 --- a/tests/orm/nodes/data/test_data.py +++ b/tests/orm/nodes/data/test_data.py @@ -9,6 +9,8 @@ """Tests for the :class:`aiida.orm.nodes.data.data:Data` class.""" import os +import tempfile +from contextlib import contextmanager import numpy import pytest @@ -176,11 +178,20 @@ def test_constructor(): assert node.source == source -def test_data_exporters(data_plugin, generate_class_instance): - """Verify that the return value of the export methods of all `Data` sub classes have the correct type. +@contextmanager +def temporary_directory(): + """Context manager that changes to a temporary directory.""" + original_cwd = os.getcwd() + with tempfile.TemporaryDirectory() as temp_dir: + try: + os.chdir(temp_dir) + yield temp_dir + finally: + os.chdir(original_cwd) - It should be a tuple where the first should be a byte string and the second a dictionary. - """ + +def test_data_exporters(data_plugin, generate_class_instance): + """Verify that the return value of the export methods of all `Data` sub classes have the correct type.""" export_formats = data_plugin.get_export_formats() if not export_formats: @@ -188,7 +199,8 @@ def test_data_exporters(data_plugin, generate_class_instance): instance = generate_class_instance(data_plugin) - for fileformat in export_formats: - content, dictionary = instance._exportcontent(fileformat) - assert isinstance(content, bytes) - assert isinstance(dictionary, dict) + with temporary_directory(): + for fileformat in export_formats: + content, dictionary = instance._exportcontent(fileformat) + assert isinstance(content, bytes) + assert isinstance(dictionary, dict)