@@ -48,7 +48,7 @@ def __init__(self, *args):
48
48
49
49
def _assert_fprogress (self , entries ):
50
50
assert 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 ():
52
52
assert call_count == 2
53
53
# END for each item in progress map
54
54
self ._reset_progress ()
@@ -86,7 +86,7 @@ def test_index_file_base(self):
86
86
assert index .version > 0
87
87
88
88
# test entry
89
- entry = index .entries .itervalues (). next ( )
89
+ entry = next ( iter ( index .entries .values ()) )
90
90
for attr in ("path" , "ctime" , "mtime" , "dev" , "inode" , "mode" , "uid" ,
91
91
"gid" , "size" , "binsha" , "hexsha" , "stage" ):
92
92
getattr (entry , attr )
@@ -100,7 +100,7 @@ def test_index_file_base(self):
100
100
# test stage
101
101
index_merge = IndexFile (self .rorepo , fixture_path ("index_merge" ))
102
102
assert 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 ))
104
104
105
105
# write the data - it must match the original
106
106
tmpfile = tempfile .mktemp ()
@@ -167,7 +167,7 @@ def test_index_file_from_tree(self, rw_repo):
167
167
assert unmerged_blob_map
168
168
169
169
# 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 ())
171
171
tree = three_way_index .write_tree ()
172
172
assert isinstance (tree , Tree )
173
173
num_blobs = 0
@@ -201,7 +201,7 @@ def test_index_merge_tree(self, rw_repo):
201
201
# Add a change with a NULL sha that should conflict with next_commit. We
202
202
# pretend there was a change, but we do not even bother adding a proper
203
203
# 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 ]))
205
205
# try write flag
206
206
self ._assert_entries (rw_repo .index .add ([manifest_fake_entry ], write = False ))
207
207
# 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):
236
236
# now make a proper three way merge with unmerged entries
237
237
unmerged_tree = IndexFile .from_tree (rw_repo , parent_commit , tree , next_commit )
238
238
unmerged_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 ]
240
240
241
241
@with_rw_repo ('0.1.6' )
242
242
def test_index_file_diffing (self , rw_repo ):
@@ -295,7 +295,7 @@ def test_index_file_diffing(self, rw_repo):
295
295
assert index .diff (None )
296
296
297
297
# 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"
299
299
file_path = os .path .join (rw_repo .working_tree_dir , "CHANGES" )
300
300
fp = open (file_path , "wb" )
301
301
fp .write (new_data )
@@ -312,7 +312,7 @@ def test_index_file_diffing(self, rw_repo):
312
312
313
313
# test full checkout
314
314
test_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" )
316
316
rval = index .checkout (None , force = True , fprogress = self ._fprogress )
317
317
assert 'CHANGES' in list (rval )
318
318
self ._assert_fprogress ([None ])
@@ -336,7 +336,7 @@ def test_index_file_diffing(self, rw_repo):
336
336
self .failUnlessRaises (CheckoutError , index .checkout , paths = ["doesnt/exist" ])
337
337
338
338
# checkout file with modifications
339
- append_data = "hello"
339
+ append_data = b "hello"
340
340
fp = open (test_file , "ab" )
341
341
fp .write (append_data )
342
342
fp .close ()
@@ -346,13 +346,13 @@ def test_index_file_diffing(self, rw_repo):
346
346
assert len (e .failed_files ) == 1 and e .failed_files [0 ] == os .path .basename (test_file )
347
347
assert (len (e .failed_files ) == len (e .failed_reasons )) and isinstance (e .failed_reasons [0 ], string_types )
348
348
assert len (e .valid_files ) == 0
349
- assert open (test_file ).read ().endswith (append_data )
349
+ assert open (test_file , 'rb' ).read ().endswith (append_data )
350
350
else :
351
351
raise AssertionError ("Exception CheckoutError not thrown" )
352
352
353
353
# if we force it it should work
354
354
index .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 )
356
356
357
357
# checkout directory
358
358
shutil .rmtree (os .path .join (rw_repo .working_tree_dir , "lib" ))
@@ -379,14 +379,15 @@ def test_index_mutation(self, rw_repo):
379
379
380
380
uname = "Some Developer"
381
381
umail = "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 )
384
385
385
386
# remove all of the files, provide a wild mix of paths, BaseIndexEntries,
386
387
# IndexEntries
387
388
def mixed_iterator ():
388
389
count = 0
389
- for entry in index .entries .itervalues ():
390
+ for entry in index .entries .values ():
390
391
type_id = count % 4
391
392
if type_id == 0 : # path
392
393
yield entry .path
@@ -500,7 +501,7 @@ def mixed_iterator():
500
501
501
502
# mode 0 not allowed
502
503
null_hex_sha = Diff .NULL_HEX_SHA
503
- null_bin_sha = "\0 " * 20
504
+ null_bin_sha = b "\0 " * 20
504
505
self .failUnlessRaises (ValueError , index .reset (
505
506
new_commit ).add , [BaseIndexEntry ((0 , null_bin_sha , 0 , "doesntmatter" ))])
506
507
@@ -526,7 +527,7 @@ def mixed_iterator():
526
527
assert S_ISLNK (index .entries [index .entry_key ("my_real_symlink" , 0 )].mode )
527
528
528
529
# 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
530
531
# END real symlink test
531
532
532
533
# add fake symlink and assure it checks-our as symlink
@@ -618,7 +619,7 @@ def make_paths():
618
619
619
620
for fid in range (3 ):
620
621
fname = 'newfile%i' % fid
621
- open (fname , 'wb' ).write ("abcd" )
622
+ open (fname , 'wb' ).write (b "abcd" )
622
623
yield Blob (rw_repo , Blob .NULL_BIN_SHA , 0o100644 , fname )
623
624
# END for each new file
624
625
# END path producer
@@ -716,5 +717,5 @@ def test_index_bare_add(self, rw_bare_repo):
716
717
try :
717
718
rw_bare_repo .index .add ([path ])
718
719
except 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 )
720
721
assert asserted , "Adding using a filename is not correctly asserted."
0 commit comments