@@ -48,7 +48,7 @@ def __init__(self, *args):
4848
4949def _assert_fprogress (self ,entries ):
5050assert len (entries )== len (self ._fprogress_map )
51- for path ,call_count in self ._fprogress_map .iteritems ():
51+ for path ,call_count in self ._fprogress_map .items ():
5252assert call_count == 2
5353# END for each item in progress map
5454self ._reset_progress ()
@@ -86,7 +86,7 @@ def test_index_file_base(self):
8686assert index .version > 0
8787
8888# test entry
89- entry = index .entries .itervalues (). next ( )
89+ entry = next ( iter ( index .entries .values ()) )
9090for attr in ("path" ,"ctime" ,"mtime" ,"dev" ,"inode" ,"mode" ,"uid" ,
9191"gid" ,"size" ,"binsha" ,"hexsha" ,"stage" ):
9292getattr (entry ,attr )
@@ -100,7 +100,7 @@ def test_index_file_base(self):
100100# test stage
101101index_merge = IndexFile (self .rorepo ,fixture_path ("index_merge" ))
102102assert len (index_merge .entries )== 106
103- assert len (list (e for e in index_merge .entries .itervalues ()if e .stage != 0 ))
103+ assert len (list (e for e in index_merge .entries .values ()if e .stage != 0 ))
104104
105105# write the data - it must match the original
106106tmpfile = tempfile .mktemp ()
@@ -167,7 +167,7 @@ def test_index_file_from_tree(self, rw_repo):
167167assert unmerged_blob_map
168168
169169# pick the first blob at the first stage we find and use it as resolved version
170- three_way_index .resolve_blobs (l [0 ][1 ]for l in unmerged_blob_map .itervalues ())
170+ three_way_index .resolve_blobs (l [0 ][1 ]for l in unmerged_blob_map .values ())
171171tree = three_way_index .write_tree ()
172172assert isinstance (tree ,Tree )
173173num_blobs = 0
@@ -201,7 +201,7 @@ def test_index_merge_tree(self, rw_repo):
201201# Add a change with a NULL sha that should conflict with next_commit. We
202202# pretend there was a change, but we do not even bother adding a proper
203203# sha for it ( which makes things faster of course )
204- manifest_fake_entry = BaseIndexEntry ((manifest_entry [0 ],"\0 " * 20 ,0 ,manifest_entry [3 ]))
204+ manifest_fake_entry = BaseIndexEntry ((manifest_entry [0 ],b "\0 "* 20 ,0 ,manifest_entry [3 ]))
205205# try write flag
206206self ._assert_entries (rw_repo .index .add ([manifest_fake_entry ],write = False ))
207207# add actually resolves the null-hex-sha for us as a feature, but we can
@@ -236,7 +236,7 @@ def test_index_merge_tree(self, rw_repo):
236236# now make a proper three way merge with unmerged entries
237237unmerged_tree = IndexFile .from_tree (rw_repo ,parent_commit ,tree ,next_commit )
238238unmerged_blobs = unmerged_tree .unmerged_blobs ()
239- assert len (unmerged_blobs )== 1 and unmerged_blobs .keys ()[0 ]== manifest_key [0 ]
239+ assert len (unmerged_blobs )== 1 and list ( unmerged_blobs .keys () )[0 ]== manifest_key [0 ]
240240
241241@with_rw_repo ('0.1.6' )
242242def test_index_file_diffing (self ,rw_repo ):
@@ -295,7 +295,7 @@ def test_index_file_diffing(self, rw_repo):
295295assert index .diff (None )
296296
297297# reset the working copy as well to current head,to pull 'back' as well
298- new_data = "will be reverted"
298+ new_data = b "will be reverted"
299299file_path = os .path .join (rw_repo .working_tree_dir ,"CHANGES" )
300300fp = open (file_path ,"wb" )
301301fp .write (new_data )
@@ -312,7 +312,7 @@ def test_index_file_diffing(self, rw_repo):
312312
313313# test full checkout
314314test_file = os .path .join (rw_repo .working_tree_dir ,"CHANGES" )
315- open (test_file ,'ab' ).write ("some data" )
315+ open (test_file ,'ab' ).write (b "some data" )
316316rval = index .checkout (None ,force = True ,fprogress = self ._fprogress )
317317assert 'CHANGES' in list (rval )
318318self ._assert_fprogress ([None ])
@@ -336,7 +336,7 @@ def test_index_file_diffing(self, rw_repo):
336336self .failUnlessRaises (CheckoutError ,index .checkout ,paths = ["doesnt/exist" ])
337337
338338# checkout file with modifications
339- append_data = "hello"
339+ append_data = b "hello"
340340fp = open (test_file ,"ab" )
341341fp .write (append_data )
342342fp .close ()
@@ -346,13 +346,13 @@ def test_index_file_diffing(self, rw_repo):
346346assert len (e .failed_files )== 1 and e .failed_files [0 ]== os .path .basename (test_file )
347347assert (len (e .failed_files )== len (e .failed_reasons ))and isinstance (e .failed_reasons [0 ],string_types )
348348assert len (e .valid_files )== 0
349- assert open (test_file ).read ().endswith (append_data )
349+ assert open (test_file , 'rb' ).read ().endswith (append_data )
350350else :
351351raise AssertionError ("Exception CheckoutError not thrown" )
352352
353353# if we force it it should work
354354index .checkout (test_file ,force = True )
355- assert not open (test_file ).read ().endswith (append_data )
355+ assert not open (test_file , 'rb' ).read ().endswith (append_data )
356356
357357# checkout directory
358358shutil .rmtree (os .path .join (rw_repo .working_tree_dir ,"lib" ))
@@ -379,14 +379,15 @@ def test_index_mutation(self, rw_repo):
379379
380380uname = "Some Developer"
381381umail = "sd@company.com"
382- rw_repo .config_writer ().set_value ("user" ,"name" ,uname )
383- rw_repo .config_writer ().set_value ("user" ,"email" ,umail )
382+ writer = rw_repo .config_writer ()
383+ writer .set_value ("user" ,"name" ,uname )
384+ writer .set_value ("user" ,"email" ,umail )
384385
385386# remove all of the files, provide a wild mix of paths, BaseIndexEntries,
386387# IndexEntries
387388def mixed_iterator ():
388389count = 0
389- for entry in index .entries .itervalues ():
390+ for entry in index .entries .values ():
390391type_id = count % 4
391392if type_id == 0 :# path
392393yield entry .path
@@ -500,7 +501,7 @@ def mixed_iterator():
500501
501502# mode 0 not allowed
502503null_hex_sha = Diff .NULL_HEX_SHA
503- null_bin_sha = "\0 " * 20
504+ null_bin_sha = b "\0 "* 20
504505self .failUnlessRaises (ValueError ,index .reset (
505506new_commit ).add , [BaseIndexEntry ((0 ,null_bin_sha ,0 ,"doesntmatter" ))])
506507
@@ -526,7 +527,7 @@ def mixed_iterator():
526527assert S_ISLNK (index .entries [index .entry_key ("my_real_symlink" ,0 )].mode )
527528
528529# we expect only the target to be written
529- assert index .repo .odb .stream (entries [0 ].binsha ).read ()== target
530+ assert index .repo .odb .stream (entries [0 ].binsha ).read (). decode ( 'ascii' ) == target
530531# END real symlink test
531532
532533# add fake symlink and assure it checks-our as symlink
@@ -618,7 +619,7 @@ def make_paths():
618619
619620for fid in range (3 ):
620621fname = 'newfile%i' % fid
621- open (fname ,'wb' ).write ("abcd" )
622+ open (fname ,'wb' ).write (b "abcd" )
622623yield Blob (rw_repo ,Blob .NULL_BIN_SHA ,0o100644 ,fname )
623624# END for each new file
624625# END path producer
@@ -716,5 +717,5 @@ def test_index_bare_add(self, rw_bare_repo):
716717try :
717718rw_bare_repo .index .add ([path ])
718719except Exception as e :
719- asserted = "does not have a working tree" in e . message
720+ asserted = "does not have a working tree" in str ( e )
720721assert asserted ,"Adding using a filename is not correctly asserted."