Incorporate temp file check in teh GenericViewTestCase class.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group
|
||||
@@ -16,11 +18,15 @@ from user_management.tests import (
|
||||
TEST_USER_EMAIL, TEST_USER_USERNAME, TEST_USER_PASSWORD
|
||||
)
|
||||
|
||||
from ..settings import setting_temporary_directory
|
||||
|
||||
from .literals import TEST_VIEW_NAME, TEST_VIEW_URL
|
||||
|
||||
|
||||
class GenericViewTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.temp_items = len(os.listdir(setting_temporary_directory.value))
|
||||
|
||||
self.has_test_view = False
|
||||
self.admin_user = get_user_model().objects.create_superuser(
|
||||
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
|
||||
@@ -45,6 +51,10 @@ class GenericViewTestCase(TestCase):
|
||||
if self.has_test_view:
|
||||
urlpatterns.pop(0)
|
||||
|
||||
self.assertEqual(
|
||||
self.temp_items, len(os.listdir(setting_temporary_directory.value))
|
||||
)
|
||||
|
||||
def add_test_view(self, test_object):
|
||||
from mayan.urls import urlpatterns
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import types
|
||||
|
||||
@@ -51,10 +52,13 @@ def fs_cleanup(filename, suppress_exceptions=True):
|
||||
try:
|
||||
os.remove(filename)
|
||||
except OSError:
|
||||
if suppress_exceptions:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
try:
|
||||
shutil.rmtree(filename)
|
||||
except OSError:
|
||||
if suppress_exceptions:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def get_descriptor(file_input, read=True):
|
||||
|
||||
Reference in New Issue
Block a user