kopia lustrzana https://gitlab.com/marnanel/chapeau
KepiTestCase
The only difference from django.test.TestCase is that KepiTestCase redirects logging to stdout in setUp, and undoes it again in tearDown. This is because Django's "./manage.py test" suppresses stderr, so you can't read the debug logs otherwise. Put into use in a couple of files where it was needed immediately. Will add more later.main
rodzic
b00f844d84
commit
94309cc77d
|
@ -0,0 +1,21 @@
|
|||
import logging
|
||||
import sys
|
||||
import django
|
||||
|
||||
logger = logging.getLogger('kepi')
|
||||
|
||||
class KepiTestCase(django.test.TestCase):
|
||||
"""
|
||||
A test case.
|
||||
|
||||
It turns on logging to stdout.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self._logging_stream_handler = logging.StreamHandler(sys.stdout)
|
||||
logger.addHandler(self._logging_stream_handler)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
logger.removeHandler(self._logging_stream_handler)
|
|
@ -8,12 +8,12 @@ import logging
|
|||
logger = logging.getLogger(name="kepi")
|
||||
|
||||
from unittest import skip
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from kepi.sombrero_sendpub.fetch import fetch
|
||||
from kepi.trilby_api.models import RemotePerson, Person, Status
|
||||
from kepi.trilby_api.tests import create_local_person
|
||||
from kepi.sombrero_sendpub.collections import Collection
|
||||
from kepi.kepi.testing import KepiTestCase
|
||||
from . import suppress_thread_exceptions
|
||||
import httpretty
|
||||
import requests
|
||||
|
@ -166,7 +166,7 @@ EXAMPLE_COMPLEX_COLLECTION_PAGE_2 = """{
|
|||
EXAMPLE_COMPLEX_COLLECTION_URL,
|
||||
)
|
||||
|
||||
class TestFetchRemoteUser(TestCase):
|
||||
class TestFetchRemoteUser(KepiTestCase):
|
||||
|
||||
@httpretty.activate
|
||||
def test_fetch(self):
|
||||
|
@ -527,9 +527,10 @@ class TestFetchRemoteUser(TestCase):
|
|||
len(EXAMPLE_COMPLEX_COLLECTION_MEMBERS),
|
||||
msg="Collection has a length")
|
||||
|
||||
class TestFetchLocalUser(TestCase):
|
||||
class TestFetchLocalUser(KepiTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self._alice = create_local_person(
|
||||
name = 'alice',
|
||||
)
|
||||
|
@ -588,5 +589,5 @@ class TestFetchLocalUser(TestCase):
|
|||
None,
|
||||
)
|
||||
|
||||
class TestFetchStatus(TestCase):
|
||||
class TestFetchStatus(KepiTestCase):
|
||||
pass
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from kepi.trilby_api.utils import *
|
||||
from kepi.kepi.testing import KepiTestCase
|
||||
|
||||
class Tests(TestCase):
|
||||
class Tests(KepiTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
settings.KEPI['LOCAL_OBJECT_HOSTNAME'] = 'testserver'
|
||||
|
||||
def test_is_local_user_url(self):
|
||||
|
|
Ładowanie…
Reference in New Issue