Skip to content

Commit 9d80fb0

Browse files
committed
tmp_dir test without patching
1 parent ce4973e commit 9d80fb0

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

tests/tools/archive/test_simple.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,27 +158,15 @@ def crashing_filter(_):
158158

159159

160160
@pytest.mark.usefixtures('aiida_profile_clean')
161-
def test_tmp_dir_custom_valid(tmp_path):
162-
"""Test using a custom valid temporary directory."""
163-
from unittest.mock import patch
164-
161+
def test_tmp_dir(tmp_path, aiida_profile_clean):
162+
"""Test that tmp_dir parameter is used correctly."""
165163
node = orm.Int(42).store()
166164
custom_tmp = tmp_path / 'custom_tmp'
167165
custom_tmp.mkdir()
168-
filename = tmp_path / 'export.aiida' # Put output file outside custom_tmp
169-
170-
with patch('tempfile.TemporaryDirectory') as mock_temp_dir:
171-
# Create the actual temp directory that the mock returns
172-
actual_temp_dir = custom_tmp / 'temp_dir'
173-
actual_temp_dir.mkdir()
174-
175-
mock_temp_dir.return_value.__enter__.return_value = str(actual_temp_dir)
176-
mock_temp_dir.return_value.__exit__.return_value = None
177-
178-
create_archive([node], filename=filename, tmp_dir=custom_tmp)
166+
filename = tmp_path / 'export.aiida'
179167

180-
# Check that TemporaryDirectory was called with custom directory
181-
mock_temp_dir.assert_called_once_with(dir=custom_tmp, prefix='.aiida-export-')
168+
create_archive([node], filename=filename, tmp_dir=custom_tmp)
169+
assert filename.exists()
182170

183171

184172
@pytest.mark.usefixtures('aiida_profile_clean')

0 commit comments

Comments
 (0)