mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
tests: use pytest tmp_path fixture instead of hardcoded /tmp paths
tmp_path is a built-in pytest fixture providing a unique per-test tempdir. Hardcoded /tmp paths break when multiple builders run tests concurrently (e.g. Nix parallel builds): leftover or colliding files cause spurious failures. Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
This commit is contained in:
@@ -315,10 +315,10 @@ def test_write_configuration_with_already_existing_file_raises():
|
||||
module.write_configuration('config.yaml', 'config: yaml')
|
||||
|
||||
|
||||
def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise():
|
||||
def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise(tmp_path):
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
module.write_configuration('/tmp/config.yaml', 'config: yaml', overwrite=True)
|
||||
module.write_configuration(str(tmp_path / 'config.yaml'), 'config: yaml', overwrite=True)
|
||||
|
||||
|
||||
def test_write_configuration_with_already_existing_directory_does_not_raise():
|
||||
|
||||
@@ -222,11 +222,11 @@ def test_parse_configuration_merges_include():
|
||||
assert logs == []
|
||||
|
||||
|
||||
def test_parse_configuration_raises_for_missing_config_file():
|
||||
def test_parse_configuration_raises_for_missing_config_file(tmp_path):
|
||||
with pytest.raises(FileNotFoundError):
|
||||
module.parse_configuration(
|
||||
'/tmp/config.yaml',
|
||||
'/tmp/schema.yaml',
|
||||
str(tmp_path / 'nonexistent' / 'config.yaml'),
|
||||
str(tmp_path / 'nonexistent' / 'schema.yaml'),
|
||||
arguments={'global': flexmock()},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user