Mozilla/mozilla/config/tests/unit-LineEndings.py
axel%pike.org 537dba8842 bug 409956, python preprocessor ignores #filter emptyLines, aka line endings hell, r=ted, a=ss
git-svn-id: svn://10.0.0.236/trunk@253585 18797224-902f-48f8-a5cc-f745e15eee43
2008-08-14 10:09:02 +00:00

47 lines
1.1 KiB
Python

import unittest
from StringIO import StringIO
import os
import sys
import os.path
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from Preprocessor import Preprocessor
class TestLineEndings(unittest.TestCase):
"""
Unit tests for the Context class
"""
def setUp(self):
self.pp = Preprocessor()
self.pp.out = StringIO()
self.tempnam = os.tempnam('.')
def tearDown(self):
os.remove(self.tempnam)
def createFile(self, lineendings):
f = open(self.tempnam, 'wb')
for line, ending in zip(['a', '#literal b', 'c'], lineendings):
f.write(line+ending)
f.close()
def testMac(self):
self.createFile(['\x0D']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
def testUnix(self):
self.createFile(['\x0A']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
def testWindows(self):
self.createFile(['\x0D\x0A']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
if __name__ == '__main__':
unittest.main()