1
0
mirror of https://github.com/django/django.git synced 2024-12-28 12:06:22 +00:00

[1.8.x] Refs #24625 -- Filtered docutils warnings output in tests

Instead of setting ``warning_stream`` in the docutils config overrides
to ``False`` I opted for filtering the stderr in the tests to keep the
error output showing up in server logs.

Thanks Tim Graham for the report and review

Backport of 3caf7efb44 from master
This commit is contained in:
Markus Holtermann 2015-04-13 17:23:20 +02:00
parent 496800b3bf
commit 584c6591a3

View File

@ -8,6 +8,7 @@ from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.test import TestCase, modify_settings, override_settings
from django.test.utils import captured_stderr
from .models import Company, Person
@ -210,9 +211,8 @@ class TestModelDetailView(AdminDocsTestCase):
def setUp(self):
self.client.login(username='super', password='secret')
self.response = self.client.get(
reverse('django-admindocs-models-detail',
args=['admin_docs', 'person']))
with captured_stderr() as self.docutils_stderr:
self.response = self.client.get(reverse('django-admindocs-models-detail', args=['admin_docs', 'person']))
def test_method_excludes(self):
"""
@ -285,6 +285,9 @@ class TestModelDetailView(AdminDocsTestCase):
self.assertContains(self.response, '.. raw:: html\n :file: admin_docs/evilfile.txt')
self.assertContains(self.response, '<p>&quot;include&quot; directive disabled.</p>',)
self.assertContains(self.response, '.. include:: admin_docs/evilfile.txt')
out = self.docutils_stderr.getvalue()
self.assertIn('"raw" directive disabled', out)
self.assertIn('"include" directive disabled', out)
def test_model_with_many_to_one(self):
link = '<a class="reference external" href="/admindocs/models/%s/">%s</a>'