summaryrefslogtreecommitdiff
path: root/testing/test_soledad/util.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-09-24 11:32:13 -0300
committerdrebs <drebs@leap.se>2016-09-30 09:08:03 -0300
commitd5bbe37495ee733be5f78de72364f3ec48ed7a0d (patch)
treea23ed57a323bd9e8db088700970d0f6f53e1da91 /testing/test_soledad/util.py
parentb1a7b538ab851c9e1aab3be5ba31411d658a4773 (diff)
[test] use pytest tmpdir fixture in all tests
Tests that were imported from u1db or created on top of that structure were leaving temporary directories behind. This could cause problems in test servers, either by filling the partition or by extrapolating the maximum amount of files in a directory. This commit replaces all usages of temporary directories in the old test structure by pytest tmpdir fixture, which properly cares for removing temporary directories.
Diffstat (limited to 'testing/test_soledad/util.py')
-rw-r--r--testing/test_soledad/util.py13
1 files changed, 1 insertions, 12 deletions
diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py
index e23d185e..d53f6cda 100644
--- a/testing/test_soledad/util.py
+++ b/testing/test_soledad/util.py
@@ -22,8 +22,6 @@ Utilities used by multiple test suites.
import os
-import tempfile
-import shutil
import random
import string
import couchdb
@@ -43,7 +41,6 @@ from leap.soledad.common import l2db
from leap.soledad.common.l2db import sync
from leap.soledad.common.l2db.remote import http_database
-from leap.soledad.common import soledad_assert
from leap.soledad.common.document import SoledadDocument
from leap.soledad.common.couch import CouchDatabase
from leap.soledad.common.couch.state import CouchServerState
@@ -226,6 +223,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
"""
defer_sync_encryption = False
+ @pytest.mark.usefixtures("method_tmpdir")
def setUp(self):
# The following snippet comes from BaseLeapTest.setUpClass, but we
# repeat it here because twisted.trial does not work with
@@ -233,7 +231,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
self.old_path = os.environ['PATH']
self.old_home = os.environ['HOME']
- self.tempdir = tempfile.mkdtemp(prefix="leap_tests-")
self.home = self.tempdir
bin_tdir = os.path.join(
self.tempdir,
@@ -276,14 +273,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
self._soledad.secrets.secrets_path]:
if os.path.isfile(f):
os.unlink(f)
- # The following snippet comes from BaseLeapTest.setUpClass, but we
- # repeat it here because twisted.trial does not work with
- # setUpClass/tearDownClass.
- soledad_assert(
- self.tempdir.startswith('/tmp/leap_tests-'),
- "beware! tried to remove a dir which does not "
- "live in temporal folder!")
- shutil.rmtree(self.tempdir)
from twisted.internet import reactor
reactor.addSystemEventTrigger(