@@ -376,24 +376,12 @@ def _verify_response(self, name, subs, response, exp_code,
376
376
self .assertEqual (exp_code , response .status_code , message )
377
377
response_data = response .content
378
378
response_data = pretty_data (response_data )
379
- if not os . path . exists ( self ._get_template (name ,
380
- self . microversion ) ):
379
+ template_path = self ._get_template (name , self . microversion )
380
+ if not os . path . exists ( template_path ):
381
381
self ._write_template (name , response_data )
382
382
template_data = response_data
383
383
else :
384
384
template_data = self ._read_template (name )
385
- if (self .generate_samples and
386
- not os .path .exists (self ._get_sample (
387
- name , self .microversion ))):
388
-
389
- self ._write_sample (name , response_data )
390
- sample_data = response_data
391
- else :
392
- with open (self ._get_sample (name ,
393
- self .microversion )) as sample :
394
- sample_data = sample .read ()
395
- if update_links :
396
- sample_data = self ._update_links (sample_data )
397
385
398
386
try :
399
387
template_data = objectify (template_data )
@@ -403,11 +391,20 @@ def _verify_response(self, name, subs, response, exp_code,
403
391
except NoMatch as e :
404
392
raise NoMatch ("\n Failed to match Template to Response: \n %s\n "
405
393
"Template: %s\n \n "
394
+ "Template Path: %s\n \n "
406
395
"Response: %s\n \n " %
407
- (e ,
408
- pp .pformat (template_data ),
396
+ (e , pp .pformat (template_data ), template_path ,
409
397
pp .pformat (response_data )))
410
398
399
+ sample_path = self ._get_sample (name , self .microversion )
400
+ if (self .generate_samples and not os .path .exists (sample_path )):
401
+ self ._write_sample (name , response_data )
402
+ sample_data = response_data
403
+ else :
404
+ with open (sample_path ) as sample :
405
+ sample_data = sample .read ()
406
+ if update_links :
407
+ sample_data = self ._update_links (sample_data )
411
408
try :
412
409
# NOTE(danms): replace some of the subs with patterns for the
413
410
# doc/api_samples check, which won't have things like the
@@ -426,12 +423,13 @@ def _verify_response(self, name, subs, response, exp_code,
426
423
except NoMatch as e :
427
424
raise NoMatch ("\n Failed to match Template to Sample: \n %s\n "
428
425
"Template: %s\n \n "
426
+ "Template Path: %s\n \n "
429
427
"Sample: %s\n \n "
428
+ "sample Path: %s\n \n "
430
429
"Hint: does your test need to override "
431
430
"ApiSampleTestBase.generalize_subs()?" %
432
- (e ,
433
- pp .pformat (template_data ),
434
- pp .pformat (sample_data )))
431
+ (e , pp .pformat (template_data ), template_path ,
432
+ pp .pformat (response_data ), sample_path ))
435
433
436
434
def _get_host (self ):
437
435
return 'http://openstack.example.com'
0 commit comments