@@ -61,14 +61,14 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False)
61
61
stream .seek (0 )
62
62
63
63
istream = rwrepo .odb .store (IStream (Commit .type , streamlen , stream ))
64
- assert istream .hexsha == cm .hexsha .encode ('ascii' )
64
+ assert_equal ( istream .hexsha , cm .hexsha .encode ('ascii' ) )
65
65
66
66
nc = Commit (rwrepo , Commit .NULL_BIN_SHA , cm .tree ,
67
67
cm .author , cm .authored_date , cm .author_tz_offset ,
68
68
cm .committer , cm .committed_date , cm .committer_tz_offset ,
69
69
cm .message , cm .parents , cm .encoding )
70
70
71
- assert nc .parents == cm .parents
71
+ assert_equal ( nc .parents , cm .parents )
72
72
stream = BytesIO ()
73
73
nc ._serialize (stream )
74
74
ns += 1
@@ -82,7 +82,7 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False)
82
82
nc .binsha = rwrepo .odb .store (istream ).binsha
83
83
84
84
# if it worked, we have exactly the same contents !
85
- assert nc .hexsha == cm .hexsha
85
+ assert_equal ( nc .hexsha , cm .hexsha )
86
86
# END check commits
87
87
elapsed = time .time () - st
88
88
@@ -103,10 +103,10 @@ def test_bake(self):
103
103
104
104
assert_equal ("Sebastian Thiel" , commit .author .name )
105
105
assert_equal ("byronimo@gmail.com" , commit .author .email )
106
- assert commit .author == commit .committer
106
+ self . assertEqual ( commit .author , commit .committer )
107
107
assert isinstance (commit .authored_date , int ) and isinstance (commit .committed_date , int )
108
108
assert isinstance (commit .author_tz_offset , int ) and isinstance (commit .committer_tz_offset , int )
109
- assert commit .message == "Added missing information to docstrings of commit and stats module\n "
109
+ self . assertEqual ( commit .message , "Added missing information to docstrings of commit and stats module\n " )
110
110
111
111
def test_stats (self ):
112
112
commit = self .rorepo .commit ('33ebe7acec14b25c5f84f35a664803fcab2f7781' )
@@ -129,20 +129,20 @@ def check_entries(d):
129
129
130
130
# assure data is parsed properly
131
131
michael = Actor ._from_string ("Michael Trier <mtrier@gmail.com>" )
132
- assert commit .author == michael
133
- assert commit .committer == michael
134
- assert commit .authored_date == 1210193388
135
- assert commit .committed_date == 1210193388
136
- assert commit .author_tz_offset == 14400 , commit .author_tz_offset
137
- assert commit .committer_tz_offset == 14400 , commit .committer_tz_offset
138
- assert commit .message == "initial project\n "
132
+ self . assertEqual ( commit .author , michael )
133
+ self . assertEqual ( commit .committer , michael )
134
+ self . assertEqual ( commit .authored_date , 1210193388 )
135
+ self . assertEqual ( commit .committed_date , 1210193388 )
136
+ self . assertEqual ( commit .author_tz_offset , 14400 , commit .author_tz_offset )
137
+ self . assertEqual ( commit .committer_tz_offset , 14400 , commit .committer_tz_offset )
138
+ self . assertEqual ( commit .message , "initial project\n " )
139
139
140
140
def test_unicode_actor (self ):
141
141
# assure we can parse unicode actors correctly
142
142
name = u"Üäöß ÄußÉ"
143
- assert len (name ) == 9
143
+ self . assertEqual ( len (name ), 9 )
144
144
special = Actor ._from_string (u"%s <something@this.com>" % name )
145
- assert special .name == name
145
+ self . assertEqual ( special .name , name )
146
146
assert isinstance (special .name , text_type )
147
147
148
148
def test_traversal (self ):
@@ -156,44 +156,44 @@ def test_traversal(self):
156
156
# basic branch first, depth first
157
157
dfirst = start .traverse (branch_first = False )
158
158
bfirst = start .traverse (branch_first = True )
159
- assert next (dfirst ) == p0
160
- assert next (dfirst ) == p00
159
+ self . assertEqual ( next (dfirst ), p0 )
160
+ self . assertEqual ( next (dfirst ), p00 )
161
161
162
- assert next (bfirst ) == p0
163
- assert next (bfirst ) == p1
164
- assert next (bfirst ) == p00
165
- assert next (bfirst ) == p10
162
+ self . assertEqual ( next (bfirst ), p0 )
163
+ self . assertEqual ( next (bfirst ), p1 )
164
+ self . assertEqual ( next (bfirst ), p00 )
165
+ self . assertEqual ( next (bfirst ), p10 )
166
166
167
167
# at some point, both iterations should stop
168
- assert list (bfirst )[- 1 ] == first
168
+ self . assertEqual ( list (bfirst )[- 1 ], first )
169
169
stoptraverse = self .rorepo .commit ("254d04aa3180eb8b8daf7b7ff25f010cd69b4e7d" ).traverse (as_edge = True )
170
170
l = list (stoptraverse )
171
- assert len (l [0 ]) == 2
171
+ self . assertEqual ( len (l [0 ]), 2 )
172
172
173
173
# ignore self
174
- assert next (start .traverse (ignore_self = False )) == start
174
+ self . assertEqual ( next (start .traverse (ignore_self = False )), start )
175
175
176
176
# depth
177
- assert len (list (start .traverse (ignore_self = False , depth = 0 ))) == 1
177
+ self . assertEqual ( len (list (start .traverse (ignore_self = False , depth = 0 ))), 1 )
178
178
179
179
# prune
180
- assert next (start .traverse (branch_first = 1 , prune = lambda i , d : i == p0 )) == p1
180
+ self . assertEqual ( next (start .traverse (branch_first = 1 , prune = lambda i , d : i == p0 )), p1 )
181
181
182
182
# predicate
183
- assert next (start .traverse (branch_first = 1 , predicate = lambda i , d : i == p1 )) == p1
183
+ self . assertEqual ( next (start .traverse (branch_first = 1 , predicate = lambda i , d : i == p1 )), p1 )
184
184
185
185
# traversal should stop when the beginning is reached
186
186
self .failUnlessRaises (StopIteration , next , first .traverse ())
187
187
188
188
# parents of the first commit should be empty ( as the only parent has a null
189
189
# sha )
190
- assert len (first .parents ) == 0
190
+ self . assertEqual ( len (first .parents ), 0 )
191
191
192
192
def test_iteration (self ):
193
193
# we can iterate commits
194
194
all_commits = Commit .list_items (self .rorepo , self .rorepo .head )
195
195
assert all_commits
196
- assert all_commits == list (self .rorepo .iter_commits ())
196
+ self . assertEqual ( all_commits , list (self .rorepo .iter_commits () ))
197
197
198
198
# this includes merge commits
199
199
mcomit = self .rorepo .commit ('d884adc80c80300b4cc05321494713904ef1df2d' )
@@ -240,7 +240,7 @@ def test_ambiguous_arg_iteration(self, rw_dir):
240
240
list (rw_repo .iter_commits (rw_repo .head .ref )) # should fail unless bug is fixed
241
241
242
242
def test_count (self ):
243
- assert self .rorepo .tag ('refs/tags/0.1.5' ).commit .count () == 143
243
+ self .assertEqual ( self . rorepo .tag ('refs/tags/0.1.5' ).commit .count (), 143 )
244
244
245
245
def test_list (self ):
246
246
# This doesn't work anymore, as we will either attempt getattr with bytes, or compare 20 byte string
@@ -270,7 +270,7 @@ def test_iter_parents(self):
270
270
piter = c .iter_parents (skip = skip )
271
271
first_parent = next (piter )
272
272
assert first_parent != c
273
- assert first_parent == c .parents [0 ]
273
+ self . assertEqual ( first_parent , c .parents [0 ])
274
274
# END for each
275
275
276
276
def test_name_rev (self ):
@@ -283,7 +283,7 @@ def test_serialization(self, rwrepo):
283
283
assert_commit_serialization (rwrepo , '0.1.6' )
284
284
285
285
def test_serialization_unicode_support (self ):
286
- assert Commit .default_encoding .lower () == 'utf-8'
286
+ self . assertEqual ( Commit .default_encoding .lower (), 'utf-8' )
287
287
288
288
# create a commit with unicode in the message, and the author's name
289
289
# Verify its serialization and deserialization
@@ -292,10 +292,10 @@ def test_serialization_unicode_support(self):
292
292
assert isinstance (cmt .author .name , text_type ) # same here
293
293
294
294
cmt .message = u"üäêèß"
295
- assert len (cmt .message ) == 5
295
+ self . assertEqual ( len (cmt .message ), 5 )
296
296
297
297
cmt .author .name = u"äüß"
298
- assert len (cmt .author .name ) == 3
298
+ self . assertEqual ( len (cmt .author .name ), 3 )
299
299
300
300
cstream = BytesIO ()
301
301
cmt ._serialize (cstream )
@@ -305,8 +305,8 @@ def test_serialization_unicode_support(self):
305
305
ncmt = Commit (self .rorepo , cmt .binsha )
306
306
ncmt ._deserialize (cstream )
307
307
308
- assert cmt .author .name == ncmt .author .name
309
- assert cmt .message == ncmt .message
308
+ self . assertEqual ( cmt .author .name , ncmt .author .name )
309
+ self . assertEqual ( cmt .message , ncmt .message )
310
310
# actually, it can't be printed in a shell as repr wants to have ascii only
311
311
# it appears
312
312
cmt .author .__repr__ ()
@@ -315,8 +315,8 @@ def test_invalid_commit(self):
315
315
cmt = self .rorepo .commit ()
316
316
cmt ._deserialize (open (fixture_path ('commit_invalid_data' ), 'rb' ))
317
317
318
- assert cmt .author .name == u'E.Azer Ko�o�o�oculu' , cmt .author .name
319
- assert cmt .author .email == 'azer@kodfabrik.com' , cmt .author .email
318
+ self . assertEqual ( cmt .author .name , u'E.Azer Ko�o�o�oculu' , cmt .author .name )
319
+ self . assertEqual ( cmt .author .email , 'azer@kodfabrik.com' , cmt .author .email )
320
320
321
321
def test_gpgsig (self ):
322
322
cmt = self .rorepo .commit ()
@@ -339,7 +339,7 @@ def test_gpgsig(self):
339
339
JzJMZDRLQLFvnzqZuCjE
340
340
=przd
341
341
-----END PGP SIGNATURE-----"""
342
- assert cmt .gpgsig == fixture_sig
342
+ self . assertEqual ( cmt .gpgsig , fixture_sig )
343
343
344
344
cmt .gpgsig = "<test\n dummy\n sig>"
345
345
assert cmt .gpgsig != fixture_sig
@@ -353,7 +353,7 @@ def test_gpgsig(self):
353
353
cstream .seek (0 )
354
354
cmt .gpgsig = None
355
355
cmt ._deserialize (cstream )
356
- assert cmt .gpgsig == "<test\n dummy\n sig>"
356
+ self . assertEqual ( cmt .gpgsig , "<test\n dummy\n sig>" )
357
357
358
358
cmt .gpgsig = None
359
359
cstream = BytesIO ()
@@ -387,9 +387,13 @@ def stream(self, *args):
387
387
388
388
def test_datetimes (self ):
389
389
commit = self .rorepo .commit ('4251bd5' )
390
- assert commit .authored_date == 1255018625
391
- assert commit .committed_date == 1255026171
392
- assert commit .authored_datetime == datetime (2009 , 10 , 8 , 18 , 17 , 5 , tzinfo = tzoffset (- 7200 )), commit .authored_datetime # noqa
393
- assert commit .authored_datetime == datetime (2009 , 10 , 8 , 16 , 17 , 5 , tzinfo = utc ), commit .authored_datetime
394
- assert commit .committed_datetime == datetime (2009 , 10 , 8 , 20 , 22 , 51 , tzinfo = tzoffset (- 7200 ))
395
- assert commit .committed_datetime == datetime (2009 , 10 , 8 , 18 , 22 , 51 , tzinfo = utc ), commit .committed_datetime
390
+ self .assertEqual (commit .authored_date , 1255018625 )
391
+ self .assertEqual (commit .committed_date , 1255026171 )
392
+ self .assertEqual (commit .authored_datetime ,
393
+ datetime (2009 , 10 , 8 , 18 , 17 , 5 , tzinfo = tzoffset (- 7200 )), commit .authored_datetime ) # noqa
394
+ self .assertEqual (commit .authored_datetime ,
395
+ datetime (2009 , 10 , 8 , 16 , 17 , 5 , tzinfo = utc ), commit .authored_datetime )
396
+ self .assertEqual (commit .committed_datetime ,
397
+ datetime (2009 , 10 , 8 , 20 , 22 , 51 , tzinfo = tzoffset (- 7200 )))
398
+ self .assertEqual (commit .committed_datetime ,
399
+ datetime (2009 , 10 , 8 , 18 , 22 , 51 , tzinfo = utc ), commit .committed_datetime )
0 commit comments