19
19
from commoncode import text
20
20
from commoncode .testcase import get_test_file_pairs
21
21
22
-
23
22
"""
24
23
Data-driven tests using expectations stored in YAML files.
25
24
"""
26
25
26
+
27
27
@attr .attrs (slots = True )
28
28
class LicenseTest (object ):
29
29
"""
@@ -201,46 +201,46 @@ def closure_test_function(*args, **kwargs):
201
201
license_test .dump ()
202
202
return
203
203
204
- if expected_expressions != detected_expressions :
204
+ if detected_expressions != expected_expressions :
205
205
# On failure, we compare against more result data to get additional
206
206
# failure details, including the test_file and full match details
207
- results = expected_expressions + ['======================' , '' ]
208
- failure_trace = detected_expressions [:] + ['======================' , '' ]
207
+ expected = expected_expressions + ['======================' , '' ]
208
+ results_failure_trace = detected_expressions [:] + ['======================' , '' ]
209
209
for match in matches :
210
210
qtext , itext = get_texts (match )
211
211
rule_text_file = match .rule .text_file
212
212
if match .rule .is_from_license :
213
213
rule_data_file = rule_text_file .replace ('LICENSE' , 'yml' )
214
214
else :
215
215
rule_data_file = match .rule .data_file
216
- failure_trace .extend (['' ,
216
+ results_failure_trace .extend (['' ,
217
217
'======= MATCH ====' , repr (match ),
218
218
'======= Matched Query Text for:' ,
219
219
'file://{test_file}' .format (** locals ())
220
220
])
221
221
if test_data_file :
222
- failure_trace .append ('file://{test_data_file}' .format (** locals ()))
222
+ results_failure_trace .append ('file://{test_data_file}' .format (** locals ()))
223
223
224
- failure_trace .append ('' )
225
- failure_trace .append (qtext )
226
- failure_trace .extend (['' ,
224
+ results_failure_trace .append ('' )
225
+ results_failure_trace .append (qtext )
226
+ results_failure_trace .extend (['' ,
227
227
'======= Matched Rule Text for:' ,
228
228
'file://{rule_text_file}' .format (** locals ()),
229
229
'file://{rule_data_file}' .format (** locals ()),
230
230
'' ,
231
231
itext ,
232
232
])
233
233
if not matches :
234
- failure_trace .extend (['' ,
234
+ results_failure_trace .extend (['' ,
235
235
'======= NO MATCH ====' ,
236
236
'======= Not Matched Query Text for:' ,
237
237
'file://{test_file}' .format (** locals ())
238
238
])
239
239
if test_data_file :
240
- failure_trace .append ('file://{test_data_file}' .format (** locals ()))
240
+ results_failure_trace .append ('file://{test_data_file}' .format (** locals ()))
241
241
242
242
# this assert will always fail and provide a detailed failure trace
243
- assert '\n ' .join (results ) == '\n ' .join (failure_trace )
243
+ assert '\n ' .join (results_failure_trace ) == '\n ' .join (expected )
244
244
245
245
closure_test_function .__name__ = test_name
246
246
@@ -252,44 +252,44 @@ def closure_test_function(*args, **kwargs):
252
252
253
253
# a small test set of legalese to use in tests
254
254
mini_legalese = frozenset ([
255
- 'accordance' ,
256
- 'alternatively' ,
257
- 'according' ,
258
- 'acknowledgement' ,
259
- 'enforcement' ,
260
- 'admission' ,
261
- 'alleged' ,
262
- 'accused' ,
263
- 'determines' ,
264
- 'exceeding' ,
265
- 'assessment' ,
266
- 'exceeds' ,
267
- 'literal' ,
268
- 'existed' ,
269
- 'ignored' ,
270
- 'complementary' ,
271
- 'responded' ,
272
- 'observed' ,
273
- 'assessments' ,
274
- 'volunteer' ,
275
- 'admitted' ,
276
- 'ultimately' ,
277
- 'choices' ,
278
- 'complications' ,
279
- 'allowance' ,
280
- 'fragments' ,
281
- 'plaintiff' ,
282
- 'license' ,
283
- 'agreement' ,
284
- 'gnu' ,
285
- 'general' ,
286
- 'warranty' ,
287
- 'distribute' ,
288
- 'distribution' ,
289
- 'licensed' ,
290
- 'covered' ,
291
- 'warranties' ,
292
- 'damages' ,
293
- 'liability' ,
294
- 'means' ,
255
+ 'accordance' ,
256
+ 'alternatively' ,
257
+ 'according' ,
258
+ 'acknowledgement' ,
259
+ 'enforcement' ,
260
+ 'admission' ,
261
+ 'alleged' ,
262
+ 'accused' ,
263
+ 'determines' ,
264
+ 'exceeding' ,
265
+ 'assessment' ,
266
+ 'exceeds' ,
267
+ 'literal' ,
268
+ 'existed' ,
269
+ 'ignored' ,
270
+ 'complementary' ,
271
+ 'responded' ,
272
+ 'observed' ,
273
+ 'assessments' ,
274
+ 'volunteer' ,
275
+ 'admitted' ,
276
+ 'ultimately' ,
277
+ 'choices' ,
278
+ 'complications' ,
279
+ 'allowance' ,
280
+ 'fragments' ,
281
+ 'plaintiff' ,
282
+ 'license' ,
283
+ 'agreement' ,
284
+ 'gnu' ,
285
+ 'general' ,
286
+ 'warranty' ,
287
+ 'distribute' ,
288
+ 'distribution' ,
289
+ 'licensed' ,
290
+ 'covered' ,
291
+ 'warranties' ,
292
+ 'damages' ,
293
+ 'liability' ,
294
+ 'means' ,
295
295
])
0 commit comments