Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@
collect_ignore_glob = []
if sys.version_info < (3, 6):
collect_ignore_glob.append("*")

collect_ignore = ["test_storage.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import errno
import os
import shutil
import tempfile
import unittest
from unittest import mock

Expand Down Expand Up @@ -39,7 +40,7 @@ def func(*_args, **_kwargs):


def clean_folder(folder):
if os.path.isfile(folder):
if os.path.isdir(folder):
for filename in os.listdir(folder):
file_path = os.path.join(folder, filename)
try:
Expand All @@ -53,16 +54,12 @@ def clean_folder(folder):

# pylint: disable=unused-variable
class TestLocalFileBlob(unittest.TestCase):
@classmethod
def setup_class(cls):
os.makedirs(TEST_FOLDER, exist_ok=True)

@classmethod
def tearDownClass(cls):
shutil.rmtree(TEST_FOLDER, True)
def setUp(self):
global TEST_FOLDER
TEST_FOLDER = tempfile.mkdtemp()

def tearDown(self):
clean_folder(TEST_FOLDER)
shutil.rmtree(TEST_FOLDER, ignore_errors=True)

def test_delete(self):
blob = LocalFileBlob(os.path.join(TEST_FOLDER, "foobar"))
Expand Down Expand Up @@ -320,9 +317,12 @@ def test_lease_with_existing_lock(self):

# pylint: disable=protected-access, too-many-public-methods
class TestLocalFileStorage(unittest.TestCase):
@classmethod
def tearDownClass(cls):
shutil.rmtree(TEST_FOLDER, True)
def setUp(self):
global TEST_FOLDER
TEST_FOLDER = tempfile.mkdtemp()

def tearDown(self):
shutil.rmtree(TEST_FOLDER, ignore_errors=True)

def test_get_nothing(self):
with LocalFileStorage(os.path.join(TEST_FOLDER, "test", "a")) as stor:
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_check_storage_size_full(self):
os.makedirs(test_path, exist_ok=True)
with mock.patch.object(LocalFileStorage, "_check_and_set_folder_permissions", return_value=True):
with LocalFileStorage(test_path, 1) as stor:
stor.put(test_input)
stor.put(test_input, lease_period=0)
self.assertFalse(stor._check_storage_size())

def test_check_storage_size_not_full(self):
Expand Down
Loading