comparison tests/test-import.py @ 145:f3c430afa598

hglib: abstract out use of cStringIO.StringIO (issue4520) The cStringIO module does not exist in Python 3, but io.BytesIO does. This change prepares for the use of io.BytesIO when available by replacing all uses of cStringIO.StringIO with an object named BytesIO.
author Brett Cannon <brett@python.org>
date Fri, 13 Mar 2015 11:31:54 -0400
parents 4359cabcb0cc
children 8d7bf729a4db
comparison
equal deleted inserted replaced
144:3c59643a2bc3 145:f3c430afa598
1 import common, cStringIO, os 1 import common, os
2 from cStringIO import StringIO as BytesIO
2 import hglib 3 import hglib
3 from hglib.util import b 4 from hglib.util import b
4 5
5 patch = b(""" 6 patch = b("""
6 # HG changeset patch 7 # HG changeset patch
17 +1 18 +1
18 """) 19 """)
19 20
20 class test_import(common.basetest): 21 class test_import(common.basetest):
21 def test_basic_cstringio(self): 22 def test_basic_cstringio(self):
22 self.client.import_(cStringIO.StringIO(patch)) 23 self.client.import_(BytesIO(patch))
23 self.assertEquals(self.client.cat([b('a')]), b('1\n')) 24 self.assertEquals(self.client.cat([b('a')]), b('1\n'))
24 25
25 def test_basic_file(self): 26 def test_basic_file(self):
26 f = open('patch', 'wb') 27 f = open('patch', 'wb')
27 f.write(patch) 28 f.write(patch)