Ticket #13958: unittest_13958.3.diff

File unittest_13958.3.diff, 1.4 KB (added by Riccardo Attilio Galli, 12 years ago)
  • tests/regressiontests/views/tests/debug.py

    diff --git tests/regressiontests/views/tests/debug.py tests/regressiontests/views/tests/debug.py
    index e8a7d49..cc99c00 100644
    from __future__ import absolute_import  
    33import inspect
    44import os
    55import sys
     6import tempfile
    67
    78from django.conf import settings
    89from django.core.files.uploadedfile import SimpleUploadedFile
    class ExceptionReporterTests(TestCase):  
    169170        self.assertNotIn('<h2>Traceback ', html)
    170171        self.assertIn('<h2>Request information</h2>', html)
    171172        self.assertIn('<p>Request data not supplied</p>', html)
    172 
     173     
     174    def test_eol_support(self):
     175        """Test that the ExceptionReporter supports Unix, Windows and Macintosh EOL markers"""
     176        LINES = list(u'print %d' % i for i in range(1,6))
     177        reporter = ExceptionReporter(None, None, None, None)
     178   
     179        for newline in ['\n','\r\n','\r']:
     180            fd,filename = tempfile.mkstemp(text = False)
     181            os.write(fd, newline.join(LINES)+newline)
     182            os.close(fd)
     183           
     184            try:
     185                self.assertEqual(reporter._get_lines_from_file(filename, 3, 2), (1, LINES[1:3], LINES[3], LINES[4:]))
     186            finally:
     187                os.unlink(filename)
    173188
    174189class PlainTextReportTests(TestCase):
    175190    rf = RequestFactory()
Back to Top