Use nested tempfile fixture for cleanups
There are a couple places where we appear to leak tempfile and tempdirs
because we are creating dirs/files in the tests then not deleting them
when we are done. Address this by using the nested tempfile fixture
which will nest all tempfiles and tempdirs in a tempdir that the fixture
cleans up when the test is completed.
Change-Id: I2818ed48823c544bb1be6b4e1e58f78109197bc1
diff --git a/tests/unit/test_encryption.py b/tests/unit/test_encryption.py
index b424769..0a5c0a4 100644
--- a/tests/unit/test_encryption.py
+++ b/tests/unit/test_encryption.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import fixtures
import os
import subprocess
import tempfile
@@ -26,6 +27,10 @@
def setUp(self):
super(TestEncryption, self).setUp()
self.private, self.public = encryption.generate_rsa_keypair()
+ # Because we set delete to False when using NamedTemporaryFile below
+ # we need to stick our usage of temporary files in the NestedTempfile
+ # fixture ensuring everything gets cleaned up when it is done.
+ self.useFixture(fixtures.NestedTempfile())
def test_serialization(self):
"Verify key serialization"