@@ -51,7 +51,7 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False)
5151stream .seek (0 )
5252
5353istream = rwrepo .odb .store (IStream (Commit .type ,streamlen ,stream ))
54- assert istream .hexsha == cm .hexsha
54+ assert istream .hexsha == cm .hexsha . encode ( 'ascii' )
5555
5656nc = Commit (rwrepo ,Commit .NULL_BIN_SHA ,cm .tree ,
5757cm .author ,cm .authored_date ,cm .author_tz_offset ,
@@ -129,7 +129,7 @@ def check_entries(d):
129129
130130def test_unicode_actor (self ):
131131# assure we can parse unicode actors correctly
132- name = "Üäöß ÄußÉ" . decode ( "utf-8" )
132+ name = u "Üäöß ÄußÉ"
133133assert len (name )== 9
134134special = Actor ._from_string (u"%s <something@this.com>" % name )
135135assert special .name == name
@@ -146,13 +146,13 @@ def test_traversal(self):
146146# basic branch first, depth first
147147dfirst = start .traverse (branch_first = False )
148148bfirst = start .traverse (branch_first = True )
149- assert dfirst . next ()== p0
150- assert dfirst . next ()== p00
149+ assert next (dfirst )== p0
150+ assert next (dfirst )== p00
151151
152- assert bfirst . next ()== p0
153- assert bfirst . next ()== p1
154- assert bfirst . next ()== p00
155- assert bfirst . next ()== p10
152+ assert next (bfirst )== p0
153+ assert next (bfirst )== p1
154+ assert next (bfirst )== p00
155+ assert next (bfirst )== p10
156156
157157# at some point, both iterations should stop
158158assert list (bfirst )[- 1 ]== first
@@ -161,19 +161,19 @@ def test_traversal(self):
161161assert len (l [0 ])== 2
162162
163163# ignore self
164- assert start .traverse (ignore_self = False ). next ( )== start
164+ assert next ( start .traverse (ignore_self = False ))== start
165165
166166# depth
167167assert len (list (start .traverse (ignore_self = False ,depth = 0 )))== 1
168168
169169# prune
170- assert start .traverse (branch_first = 1 ,prune = lambda i ,d :i == p0 ). next ( )== p1
170+ assert next ( start .traverse (branch_first = 1 ,prune = lambda i ,d :i == p0 ))== p1
171171
172172# predicate
173- assert start .traverse (branch_first = 1 ,predicate = lambda i ,d :i == p1 ). next ( )== p1
173+ assert next ( start .traverse (branch_first = 1 ,predicate = lambda i ,d :i == p1 ))== p1
174174
175175# traversal should stop when the beginning is reached
176- self .failUnlessRaises (StopIteration ,first .traverse (). next )
176+ self .failUnlessRaises (StopIteration ,next , first .traverse ())
177177
178178# parents of the first commit should be empty ( as the only parent has a null
179179# sha )
@@ -210,7 +210,7 @@ def test_rev_list_bisect_all(self):
210210first_parent = True ,
211211bisect_all = True )
212212
213- commits = Commit ._iter_from_process_or_stream (self .rorepo ,StringProcessAdapter (revs ))
213+ commits = Commit ._iter_from_process_or_stream (self .rorepo ,StringProcessAdapter (revs . encode ( 'ascii' ) ))
214214expected_ids = (
215215'7156cece3c49544abb6bf7a0c218eb36646fad6d' ,
216216'1f66cfbbce58b4b552b041707a12d437cc5f400a' ,
@@ -224,8 +224,10 @@ def test_count(self):
224224assert self .rorepo .tag ('refs/tags/0.1.5' ).commit .count ()== 143
225225
226226def test_list (self ):
227+ # This doesn't work anymore, as we will either attempt getattr with bytes, or compare 20 byte string
228+ # with actual 20 byte bytes. This usage makes no sense anyway
227229assert isinstance (Commit .list_items (self .rorepo ,'0.1.5' ,max_count = 5 )[
228- hex_to_bin ( '5117c9c8a4d3af19a9958677e45cda9269de1541' ) ],Commit )
230+ '5117c9c8a4d3af19a9958677e45cda9269de1541' ],Commit )
229231
230232def test_str (self ):
231233commit = Commit (self .rorepo ,Commit .NULL_BIN_SHA )
@@ -247,12 +249,12 @@ def test_iter_parents(self):
247249c = self .rorepo .commit ('0.1.5' )
248250for skip in (0 ,1 ):
249251piter = c .iter_parents (skip = skip )
250- first_parent = piter . next ()
252+ first_parent = next (piter )
251253assert first_parent != c
252254assert first_parent == c .parents [0 ]
253255# END for each
254256
255- def test_base (self ):
257+ def test_name_rev (self ):
256258name_rev = self .rorepo .head .commit .name_rev
257259assert isinstance (name_rev ,string_types )
258260
@@ -270,10 +272,10 @@ def test_serialization_unicode_support(self):
270272assert isinstance (cmt .message ,text_type )# it automatically decodes it as such
271273assert isinstance (cmt .author .name ,text_type )# same here
272274
273- cmt .message = "üäêèß" . decode ( "utf-8" )
275+ cmt .message = u "üäêèß"
274276assert len (cmt .message )== 5
275277
276- cmt .author .name = "äüß" . decode ( "utf-8" )
278+ cmt .author .name = u "äüß"
277279assert len (cmt .author .name )== 3
278280
279281cstream = BytesIO ()
@@ -292,7 +294,7 @@ def test_serialization_unicode_support(self):
292294
293295def test_gpgsig (self ):
294296cmt = self .rorepo .commit ()
295- cmt ._deserialize (open (fixture_path ('commit_with_gpgsig' )))
297+ cmt ._deserialize (open (fixture_path ('commit_with_gpgsig' ), 'rb' ))
296298
297299fixture_sig = """-----BEGIN PGP SIGNATURE-----
298300Version: GnuPG v1.4.11 (GNU/Linux)
@@ -318,7 +320,7 @@ def test_gpgsig(self):
318320
319321cstream = BytesIO ()
320322cmt ._serialize (cstream )
321- assert re .search (r"^gpgsig <test\n dummy\n sig>$" ,cstream .getvalue (),re .MULTILINE )
323+ assert re .search (r"^gpgsig <test\n dummy\n sig>$" ,cstream .getvalue (). decode ( 'ascii' ) ,re .MULTILINE )
322324
323325cstream .seek (0 )
324326cmt .gpgsig = None
@@ -328,4 +330,4 @@ def test_gpgsig(self):
328330cmt .gpgsig = None
329331cstream = BytesIO ()
330332cmt ._serialize (cstream )
331- assert not re .search (r"^gpgsig " ,cstream .getvalue (),re .MULTILINE )
333+ assert not re .search (r"^gpgsig " ,cstream .getvalue (). decode ( 'ascii' ) ,re .MULTILINE )