MCPcopy
hub / github.com/django/django / test_eol_support

Method test_eol_support

tests/view_tests/tests/test_debug.py:636–654  ·  view source on GitHub ↗

The ExceptionReporter supports Unix, Windows and Macintosh EOL markers

(self)

Source from the content-addressed store, hash-verified

634 )
635
636 def test_eol_support(self):
637 """
638 The ExceptionReporter supports Unix, Windows and Macintosh EOL markers
639 """
640 LINES = ["print %d" % i for i in range(1, 6)]
641 reporter = ExceptionReporter(None, None, None, None)
642
643 for newline in ["\n", "\r\n", "\r"]:
644 fd, filename = tempfile.mkstemp(text=False)
645 os.write(fd, (newline.join(LINES) + newline).encode())
646 os.close(fd)
647
648 try:
649 self.assertEqual(
650 reporter._get_lines_from_file(filename, 3, 2),
651 (1, LINES[1:3], LINES[3], LINES[4:]),
652 )
653 finally:
654 os.unlink(filename)
655
656 def test_no_exception(self):
657 "An exception report can be generated for just a request"

Callers

nothing calls this directly

Calls 6

_get_lines_from_fileMethod · 0.95
ExceptionReporterClass · 0.90
writeMethod · 0.45
encodeMethod · 0.45
joinMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected