mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
fix tests
This commit is contained in:
parent
266c0e0e92
commit
f51454733f
2 changed files with 8 additions and 7 deletions
|
@ -400,7 +400,7 @@ def _remove_job_dir(job_path):
|
|||
# Remove job dir
|
||||
try:
|
||||
shutil.rmtree(job_path)
|
||||
except NotADirectoryError as err:
|
||||
except (NotADirectoryError, OSError) as err:
|
||||
log.error("Unable to remove %s: %s", job_path, err)
|
||||
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ from tests.support.mock import patch
|
|||
|
||||
|
||||
def test_remove_job_dir():
|
||||
# Test that _remove_job_dir job will NotADirectoryError error
|
||||
with patch("shutil.rmtree", side_effect=NotADirectoryError("Node Corruption!")):
|
||||
_remove_job_dir("cache.json")
|
||||
# Test that _remove_job_dir job will catch error
|
||||
for e in (NotADirectoryError, OSError):
|
||||
with patch("shutil.rmtree", side_effect=e("Node Corruption!")):
|
||||
_remove_job_dir("cache.json")
|
||||
|
||||
# Test that _remove_job_dir job will not catch other file errors
|
||||
with patch("shutil.rmtree", side_effect=OSError()):
|
||||
# Test that _remove_job_dir job will not catch other errors
|
||||
with patch("shutil.rmtree", side_effect=FileExistsError()):
|
||||
try:
|
||||
_remove_job_dir("cache.json")
|
||||
except OSError:
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue