@@ -134,22 +134,6 @@ def setUp(self):
134
134
{f : item [f ] for f in item ._fields } for item in self .album .items ()
135
135
]
136
136
137
- def assertCounts (
138
- self ,
139
- mock_write ,
140
- album_count = ALBUM_COUNT ,
141
- track_count = TRACK_COUNT ,
142
- write_call_count = TRACK_COUNT ,
143
- title_starts_with = "" ,
144
- ):
145
- """Several common assertions on Album, Track and call counts."""
146
- assert len (self .lib .albums ()) == album_count
147
- assert len (self .lib .items ()) == track_count
148
- assert mock_write .call_count == write_call_count
149
- assert all (
150
- i .title .startswith (title_starts_with ) for i in self .lib .items ()
151
- )
152
-
153
137
def test_title_edit_discard (self , mock_write ):
154
138
"""Edit title for all items in the library, then discard changes."""
155
139
# Edit track titles.
@@ -159,9 +143,7 @@ def test_title_edit_discard(self, mock_write):
159
143
["c" ],
160
144
)
161
145
162
- self .assertCounts (
163
- mock_write , write_call_count = 0 , title_starts_with = "t\u00ef tle"
164
- )
146
+ assert mock_write .call_count == 0
165
147
self .assertItemFieldsModified (self .album .items (), self .items_orig , [])
166
148
167
149
def test_title_edit_apply (self , mock_write ):
@@ -173,11 +155,7 @@ def test_title_edit_apply(self, mock_write):
173
155
["a" ],
174
156
)
175
157
176
- self .assertCounts (
177
- mock_write ,
178
- write_call_count = self .TRACK_COUNT ,
179
- title_starts_with = "modified t\u00ef tle" ,
180
- )
158
+ assert mock_write .call_count == self .TRACK_COUNT
181
159
self .assertItemFieldsModified (
182
160
self .album .items (), self .items_orig , ["title" , "mtime" ]
183
161
)
@@ -191,10 +169,7 @@ def test_single_title_edit_apply(self, mock_write):
191
169
["a" ],
192
170
)
193
171
194
- self .assertCounts (
195
- mock_write ,
196
- write_call_count = 1 ,
197
- )
172
+ assert mock_write .call_count == 1
198
173
# No changes except on last item.
199
174
self .assertItemFieldsModified (
200
175
list (self .album .items ())[:- 1 ], self .items_orig [:- 1 ], []
@@ -210,9 +185,7 @@ def test_noedit(self, mock_write):
210
185
[],
211
186
)
212
187
213
- self .assertCounts (
214
- mock_write , write_call_count = 0 , title_starts_with = "t\u00ef tle"
215
- )
188
+ assert mock_write .call_count == 0
216
189
self .assertItemFieldsModified (self .album .items (), self .items_orig , [])
217
190
218
191
def test_album_edit_apply (self , mock_write ):
@@ -226,7 +199,7 @@ def test_album_edit_apply(self, mock_write):
226
199
["a" ],
227
200
)
228
201
229
- self . assertCounts ( mock_write , write_call_count = self .TRACK_COUNT )
202
+ assert mock_write . call_count == self .TRACK_COUNT
230
203
self .assertItemFieldsModified (
231
204
self .album .items (), self .items_orig , ["album" , "mtime" ]
232
205
)
@@ -249,9 +222,7 @@ def test_single_edit_add_field(self, mock_write):
249
222
# Even though a flexible attribute was written (which is not directly
250
223
# written to the tags), write should still be called since templates
251
224
# might use it.
252
- self .assertCounts (
253
- mock_write , write_call_count = 1 , title_starts_with = "t\u00ef tle"
254
- )
225
+ assert mock_write .call_count == 1
255
226
256
227
def test_a_album_edit_apply (self , mock_write ):
257
228
"""Album query (-a), edit album field, apply changes."""
@@ -263,7 +234,7 @@ def test_a_album_edit_apply(self, mock_write):
263
234
)
264
235
265
236
self .album .load ()
266
- self . assertCounts ( mock_write , write_call_count = self .TRACK_COUNT )
237
+ assert mock_write . call_count == self .TRACK_COUNT
267
238
assert self .album .album == "modified \u00e4 lbum"
268
239
self .assertItemFieldsModified (
269
240
self .album .items (), self .items_orig , ["album" , "mtime" ]
@@ -279,7 +250,7 @@ def test_a_albumartist_edit_apply(self, mock_write):
279
250
)
280
251
281
252
self .album .load ()
282
- self . assertCounts ( mock_write , write_call_count = self .TRACK_COUNT )
253
+ assert mock_write . call_count == self .TRACK_COUNT
283
254
assert self .album .albumartist == "the modified album artist"
284
255
self .assertItemFieldsModified (
285
256
self .album .items (), self .items_orig , ["albumartist" , "mtime" ]
@@ -295,9 +266,7 @@ def test_malformed_yaml(self, mock_write):
295
266
["n" ],
296
267
)
297
268
298
- self .assertCounts (
299
- mock_write , write_call_count = 0 , title_starts_with = "t\u00ef tle"
300
- )
269
+ assert mock_write .call_count == 0
301
270
302
271
def test_invalid_yaml (self , mock_write ):
303
272
"""Edit the yaml file incorrectly (resulting in a well-formed but
@@ -309,9 +278,7 @@ def test_invalid_yaml(self, mock_write):
309
278
[],
310
279
)
311
280
312
- self .assertCounts (
313
- mock_write , write_call_count = 0 , title_starts_with = "t\u00ef tle"
314
- )
281
+ assert mock_write .call_count == 0
315
282
316
283
317
284
@_common .slow_test ()
0 commit comments