Code

Ticket #13958: unittest_13958.3.diff

File unittest_13958.3.diff, 1.4 KB (added by riquito, 22 months ago)
Line 
1diff --git tests/regressiontests/views/tests/debug.py tests/regressiontests/views/tests/debug.py
2index e8a7d49..cc99c00 100644
3--- tests/regressiontests/views/tests/debug.py
4+++ tests/regressiontests/views/tests/debug.py
5@@ -3,6 +3,7 @@ from __future__ import absolute_import
6 import inspect
7 import os
8 import sys
9+import tempfile
10 
11 from django.conf import settings
12 from django.core.files.uploadedfile import SimpleUploadedFile
13@@ -169,7 +170,21 @@ class ExceptionReporterTests(TestCase):
14         self.assertNotIn('<h2>Traceback ', html)
15         self.assertIn('<h2>Request information</h2>', html)
16         self.assertIn('<p>Request data not supplied</p>', html)
17-
18+     
19+    def test_eol_support(self):
20+        """Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers"""
21+        LINES = list(u'print %d' % i for i in range(1,6))
22+        reporter = ExceptionReporter(None, None, None, None)
23+   
24+        for newline in ['\n','\r\n','\r']:
25+            fd,filename = tempfile.mkstemp(text = False)
26+            os.write(fd, newline.join(LINES)+newline)
27+            os.close(fd)
28+           
29+            try:
30+                self.assertEqual(reporter._get_lines_from_file(filename, 3, 2), (1, LINES[1:3], LINES[3], LINES[4:]))
31+            finally:
32+                os.unlink(filename)
33 
34 class PlainTextReportTests(TestCase):
35     rf = RequestFactory()