Skip to content

Commit

Permalink
gpg: Handle temp directory containing files (#5063)
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Mar 18, 2024
1 parent 82a5fb3 commit 18daab5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloudinit/gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def cleanup(self) -> None:
"""cleanup the gpg temporary directory and kill gpg"""
self.kill_gpg()
if self.temp_dir and os.path.isdir(self.temp_dir.name):
os.rmdir(self.temp_dir.name)
self.temp_dir.cleanup()

def export_armour(self, key: str) -> Optional[str]:
"""Export gpg key, armoured key gets returned"""
Expand Down
4 changes: 4 additions & 0 deletions tests/unittests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import builtins
import glob
import os
import shutil
from pathlib import Path
from unittest import mock

Expand Down Expand Up @@ -67,6 +68,9 @@ def m_gpg():
("write_file", 1),
("write_json", 1),
],
shutil: [
("rmtree", 1),
],
}


Expand Down

0 comments on commit 18daab5

Please sign in to comment.