From 27b0ff5cdaf5e446d60ae6a6201a7ce0132a13a4 Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Wed, 12 Nov 2014 12:07:43 -0500 Subject: [PATCH] cleanup files that are created for swift functional tests Currently this portion of code is also being run when running tox to debug local tests. Which is very annoying since a developer will end up with a bunch of uuid files. Rather than creating it once per run, we can have a setup/teardown that is handled safely. Change-Id: I49a0bb3d14f24c54da93458d1e3b9093a1120453 --- functional/tests/test_object.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functional/tests/test_object.py b/functional/tests/test_object.py index 396f0cb7ac..4121524ace 100644 --- a/functional/tests/test_object.py +++ b/functional/tests/test_object.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import os import uuid from functional.common import test @@ -25,9 +26,11 @@ class ObjectV1Tests(test.TestCase): CONTAINER_NAME = uuid.uuid4().hex OBJECT_NAME = uuid.uuid4().hex - # NOTE(stevemar): Not using setUp since we only want this to run once - with open(OBJECT_NAME, 'w') as f: - f.write('test content') + def setUp(self): + super(ObjectV1Tests, self).setUp() + self.addCleanup(os.remove, self.OBJECT_NAME) + with open(self.OBJECT_NAME, 'w') as f: + f.write('test content') def test_container_create(self): raw_output = self.openstack('container create ' + self.CONTAINER_NAME)