Logo Search packages:      
Sourcecode: xulrunner-1.9 version File versions

unit-LineEndings.py

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

00011 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()

Generated by  Doxygen 1.6.0   Back to index