40
40
41
41
def test_branches_getitem (testrepo ):
42
42
branch = testrepo .branches ['master' ]
43
- assert str ( branch .target ) == LAST_COMMIT
43
+ assert branch .target == LAST_COMMIT
44
44
45
45
branch = testrepo .branches .local ['i18n' ]
46
- assert str ( branch .target ) == I18N_LAST_COMMIT
46
+ assert branch .target == I18N_LAST_COMMIT
47
47
assert testrepo .branches .get ('not-exists' ) is None
48
48
with pytest .raises (KeyError ):
49
49
testrepo .branches ['not-exists' ]
@@ -59,15 +59,15 @@ def test_branches_create(testrepo):
59
59
reference = testrepo .branches .create ('version1' , commit )
60
60
assert 'version1' in testrepo .branches
61
61
reference = testrepo .branches ['version1' ]
62
- assert str ( reference .target ) == LAST_COMMIT
62
+ assert reference .target == LAST_COMMIT
63
63
64
64
# try to create existing reference
65
65
with pytest .raises (ValueError ):
66
66
testrepo .branches .create ('version1' , commit )
67
67
68
68
# try to create existing reference with force
69
69
reference = testrepo .branches .create ('version1' , commit , True )
70
- assert str ( reference .target ) == LAST_COMMIT
70
+ assert reference .target == LAST_COMMIT
71
71
72
72
73
73
def test_branches_delete (testrepo ):
@@ -92,10 +92,10 @@ def test_branches_is_not_head(testrepo):
92
92
93
93
def test_branches_rename (testrepo ):
94
94
new_branch = testrepo .branches ['i18n' ].rename ('new-branch' )
95
- assert str ( new_branch .target ) == I18N_LAST_COMMIT
95
+ assert new_branch .target == I18N_LAST_COMMIT
96
96
97
97
new_branch_2 = testrepo .branches .get ('new-branch' )
98
- assert str ( new_branch_2 .target ) == I18N_LAST_COMMIT
98
+ assert new_branch_2 .target == I18N_LAST_COMMIT
99
99
100
100
101
101
def test_branches_rename_error (testrepo ):
@@ -107,7 +107,7 @@ def test_branches_rename_error(testrepo):
107
107
def test_branches_rename_force (testrepo ):
108
108
original_branch = testrepo .branches .get ('master' )
109
109
new_branch = original_branch .rename ('i18n' , True )
110
- assert str ( new_branch .target ) == LAST_COMMIT
110
+ assert new_branch .target == LAST_COMMIT
111
111
112
112
113
113
def test_branches_rename_invalid (testrepo ):
@@ -153,15 +153,11 @@ def test_branches_with_commit(testrepo):
153
153
154
154
155
155
def test_lookup_branch_local (testrepo ):
156
- branch = testrepo .lookup_branch ('master' )
157
- assert str (branch .target ) == LAST_COMMIT
158
- branch = testrepo .lookup_branch (b'master' )
159
- assert str (branch .target ) == LAST_COMMIT
156
+ assert testrepo .lookup_branch ('master' ).target == LAST_COMMIT
157
+ assert testrepo .lookup_branch (b'master' ).target == LAST_COMMIT
160
158
161
- branch = testrepo .lookup_branch ('i18n' , BranchType .LOCAL )
162
- assert str (branch .target ) == I18N_LAST_COMMIT
163
- branch = testrepo .lookup_branch (b'i18n' , BranchType .LOCAL )
164
- assert str (branch .target ) == I18N_LAST_COMMIT
159
+ assert testrepo .lookup_branch ('i18n' , BranchType .LOCAL ).target == I18N_LAST_COMMIT
160
+ assert testrepo .lookup_branch (b'i18n' , BranchType .LOCAL ).target == I18N_LAST_COMMIT
165
161
166
162
assert testrepo .lookup_branch ('not-exists' ) is None
167
163
assert testrepo .lookup_branch (b'not-exists' ) is None
@@ -179,21 +175,18 @@ def test_listall_branches(testrepo):
179
175
180
176
def test_create_branch (testrepo ):
181
177
commit = testrepo [LAST_COMMIT ]
182
- reference = testrepo .create_branch ('version1' , commit )
178
+ testrepo .create_branch ('version1' , commit )
183
179
refs = testrepo .listall_branches ()
184
180
assert 'version1' in refs
185
- reference = testrepo .lookup_branch ('version1' )
186
- assert str (reference .target ) == LAST_COMMIT
187
- reference = testrepo .lookup_branch (b'version1' )
188
- assert str (reference .target ) == LAST_COMMIT
181
+ assert testrepo .lookup_branch ('version1' ).target == LAST_COMMIT
182
+ assert testrepo .lookup_branch (b'version1' ).target == LAST_COMMIT
189
183
190
184
# try to create existing reference
191
185
with pytest .raises (ValueError ):
192
186
testrepo .create_branch ('version1' , commit )
193
187
194
188
# try to create existing reference with force
195
- reference = testrepo .create_branch ('version1' , commit , True )
196
- assert str (reference .target ) == LAST_COMMIT
189
+ assert testrepo .create_branch ('version1' , commit , True ).target == LAST_COMMIT
197
190
198
191
199
192
def test_delete (testrepo ):
@@ -231,12 +224,9 @@ def test_branch_is_checked_out_returns_false_if_branch_is_not_checked_out(testre
231
224
232
225
233
226
def test_branch_rename_succeeds (testrepo ):
234
- original_branch = testrepo .lookup_branch ('i18n' )
235
- new_branch = original_branch .rename ('new-branch' )
236
- assert str (new_branch .target ) == I18N_LAST_COMMIT
237
-
238
- new_branch_2 = testrepo .lookup_branch ('new-branch' )
239
- assert str (new_branch_2 .target ) == I18N_LAST_COMMIT
227
+ branch = testrepo .lookup_branch ('i18n' )
228
+ assert branch .rename ('new-branch' ).target == I18N_LAST_COMMIT
229
+ assert testrepo .lookup_branch ('new-branch' ).target == I18N_LAST_COMMIT
240
230
241
231
242
232
def test_branch_rename_fails_if_destination_already_exists (testrepo ):
@@ -246,9 +236,8 @@ def test_branch_rename_fails_if_destination_already_exists(testrepo):
246
236
247
237
248
238
def test_branch_rename_not_fails_if_force_is_true (testrepo ):
249
- original_branch = testrepo .lookup_branch ('master' )
250
- new_branch = original_branch .rename ('i18n' , True )
251
- assert str (new_branch .target ) == LAST_COMMIT
239
+ branch = testrepo .lookup_branch ('master' )
240
+ assert branch .rename ('i18n' , True ).target == LAST_COMMIT
252
241
253
242
254
243
def test_branch_rename_fails_with_invalid_names (testrepo ):
0 commit comments