From 3caf7efb44712f89d6552076c240a3c898673a2c Mon Sep 17 00:00:00 2001 From: Markus Holtermann Date: Mon, 13 Apr 2015 17:23:20 +0200 Subject: [PATCH] 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 --- tests/admin_docs/tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py index a59443adf4d..76366714ec9 100644 --- a/tests/admin_docs/tests.py +++ b/tests/admin_docs/tests.py @@ -9,6 +9,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 @@ -220,9 +221,8 @@ class TestModelDetailView(TestDataMixin, 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): """ @@ -295,6 +295,9 @@ class TestModelDetailView(TestDataMixin, AdminDocsTestCase): self.assertContains(self.response, '.. raw:: html\n :file: admin_docs/evilfile.txt') self.assertContains(self.response, '

"include" directive disabled.

',) 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 = '%s'