Bug 1606340 - mozbuild/test/test_line_endings.py supports Python 3 r=firefox-build-system-reviewers,mshal

Differential Revision: https://phabricator.services.mozilla.com/D58394

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ricky Stewart 2019-12-31 15:34:57 +00:00
Родитель 381aaed084
Коммит 7c9506eeb4
3 изменённых файлов: 15 добавлений и 17 удалений

Просмотреть файл

@ -4,6 +4,7 @@ subsuite = mozbuild
[test_base.py]
[test_expression.py]
[test_licenses.py]
[test_line_endings.py]
[test_makeutil.py]
[test_mozconfig.py]
[test_mozinfo.py]

Просмотреть файл

@ -40,5 +40,4 @@ skip-if = (os == "win")
[test_containers.py]
[test_dotproperties.py]
[test_jarmaker.py]
[test_line_endings.py]
[test_util.py]

Просмотреть файл

@ -1,11 +1,10 @@
from __future__ import absolute_import, print_function
from __future__ import absolute_import, print_function, unicode_literals
import unittest
from StringIO import StringIO
import os
import os.path
from mozfile import NamedTemporaryFile
import mozunit
from six import StringIO
from mozbuild.preprocessor import Preprocessor
@ -18,30 +17,29 @@ class TestLineEndings(unittest.TestCase):
def setUp(self):
self.pp = Preprocessor()
self.pp.out = StringIO()
self.tempnam = os.tempnam('.')
self.f = NamedTemporaryFile(mode='wb')
def tearDown(self):
os.remove(self.tempnam)
self.f.close()
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()
for line, ending in zip([b'a', b'#literal b', b'c'], lineendings):
self.f.write(line+ending)
self.f.flush()
def testMac(self):
self.createFile(['\x0D']*3)
self.pp.do_include(self.tempnam)
self.createFile([b'\x0D']*3)
self.pp.do_include(self.f.name)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
def testUnix(self):
self.createFile(['\x0A']*3)
self.pp.do_include(self.tempnam)
self.createFile([b'\x0A']*3)
self.pp.do_include(self.f.name)
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.createFile([b'\x0D\x0A']*3)
self.pp.do_include(self.f.name)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')