mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
test: classes that use no database are SimpleTestCase
Ten classes ran on TestCase or TransactionTestCase although they read files, templates or scripts only. SimpleTestCase skips the transaction and refuses a database query, so a test that starts to use the database says so. LoggingConfigTestCase also removes the temporary directory it makes.
This commit is contained in:
parent
ee6b8d3e10
commit
03811cc4ab
6 changed files with 17 additions and 15 deletions
|
|
@ -4,17 +4,18 @@ path, not the process working directory."""
|
|||
import io
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
from django.test import RequestFactory, TestCase
|
||||
from django.test import RequestFactory, SimpleTestCase, TestCase
|
||||
|
||||
from webvirtcloud.log_context import RequestFilter
|
||||
from webvirtcloud.middleware import RequestIdMiddleware
|
||||
|
||||
|
||||
class LoggingConfigTestCase(TestCase):
|
||||
class LoggingConfigTestCase(SimpleTestCase):
|
||||
def test_default_handler_rotates(self):
|
||||
handler = settings.LOGGING["handlers"]["default"]
|
||||
self.assertEqual(handler["class"], "logging.handlers.RotatingFileHandler")
|
||||
|
|
@ -33,6 +34,7 @@ class LoggingConfigTestCase(TestCase):
|
|||
import tempfile
|
||||
|
||||
tmp = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, tmp)
|
||||
log = os.path.join(tmp, "nested", "wvc.log")
|
||||
env = {
|
||||
**os.environ,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue