From 17380b9dd3d5c5133baff094e952a43d81b835a4 Mon Sep 17 00:00:00 2001 From: David Stanek Date: Tue, 18 Aug 2015 21:01:27 +0000 Subject: [PATCH] Refactor: use fixtures.TempDir more Change-Id: I23c48cc6a09cdfbbd69d426993f2c9be4b6533a4 --- keystone/tests/unit/common/test_ldap.py | 8 +++----- keystone/tests/unit/ksfixtures/key_repository.py | 6 +----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/keystone/tests/unit/common/test_ldap.py b/keystone/tests/unit/common/test_ldap.py index 3dbcc06f0d..d3ce8cd230 100644 --- a/keystone/tests/unit/common/test_ldap.py +++ b/keystone/tests/unit/common/test_ldap.py @@ -12,10 +12,10 @@ # under the License. import os -import shutil import tempfile import uuid +import fixtures import ldap.dn import mock from oslo_config import cfg @@ -310,8 +310,7 @@ class SslTlsTest(tests.TestCase): def test_certdir_trust_tls(self): # We need this to actually exist, so we create a tempdir. - certdir = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, certdir) + certdir = self.useFixture(fixtures.TempDir()).path self.config_fixture.config(group='ldap', url='ldap://localhost', use_tls=True, @@ -339,8 +338,7 @@ class SslTlsTest(tests.TestCase): def test_certdir_trust_ldaps(self): # We need this to actually exist, so we create a tempdir. - certdir = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, certdir) + certdir = self.useFixture(fixtures.TempDir()).path self.config_fixture.config(group='ldap', url='ldaps://localhost', use_tls=False, diff --git a/keystone/tests/unit/ksfixtures/key_repository.py b/keystone/tests/unit/ksfixtures/key_repository.py index d1ac2ab4ee..7784bddcb8 100644 --- a/keystone/tests/unit/ksfixtures/key_repository.py +++ b/keystone/tests/unit/ksfixtures/key_repository.py @@ -10,9 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import shutil -import tempfile - import fixtures from keystone.token.providers.fernet import utils @@ -25,8 +22,7 @@ class KeyRepository(fixtures.Fixture): def setUp(self): super(KeyRepository, self).setUp() - directory = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, directory) + directory = self.useFixture(fixtures.TempDir()).path self.config_fixture.config(group='fernet_tokens', key_repository=directory)