[PATCH 2 of 3 hglib] tests: open files in binary mode so new lines aren't converted

Idan Kamara idankk86 at gmail.com
Fri Sep 9 11:10:45 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1315584602 -10800
# Node ID a0328b08e02822525c0e1fab12c18acc7991a70b
# Parent  730c42743ba31689c0c5772da7515c4c9184d334
tests: open files in binary mode so new lines aren't converted

diff --git a/tests/common.py b/tests/common.py
--- a/tests/common.py
+++ b/tests/common.py
@@ -41,7 +41,7 @@
             pass # if our setUp was overriden
 
     def append(self, path, *args):
-        f = open(path, 'a')
+        f = open(path, 'ab')
         for a in args:
             f.write(str(a))
         f.close()
diff --git a/tests/test-import.py b/tests/test-import.py
--- a/tests/test-import.py
+++ b/tests/test-import.py
@@ -22,6 +22,6 @@
         self.assertEquals(self.client.cat(['a']), '1\n')
 
     def test_basic_file(self):
-        open('patch', 'w').write(patch)
+        open('patch', 'wb').write(patch)
         self.client.import_(['patch'])
         self.assertEquals(self.client.cat(['a']), '1\n')
diff --git a/tests/test-update.py b/tests/test-update.py
--- a/tests/test-update.py
+++ b/tests/test-update.py
@@ -33,7 +33,7 @@
         self.client.commit('fourth')
         self.client.update(rev2)
         old = open('a').read()
-        open('a', 'w').write('a' + old)
+        open('a', 'wb').write('a' + old)
         u, m, r, ur = self.client.update()
         self.assertEquals(u, 0)
         self.assertEquals(m, 1)


More information about the Mercurial-devel mailing list