From 2e01dc0673006892e3b559b372a26ff9205d7c81 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 14 Dec 2012 15:18:22 -0500 Subject: Fix API samples generation. In Change: Ie46b24a65145c407d46974b63a97a84911223547 a check was added to _verify_response() to verify the samples. However, when trying to generate new samples this blocks _write_sample() because it attempts to read a non-existent file. This change ensures that the sample is created before the verification and still retains the behavior that the samples are only updated on changes. Change-Id: I1527ba71676b2e1e10bd334f2a7878404d12600c --- nova/tests/integrated/test_api_samples.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 8b78d3b51..a59ca1a29 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -227,9 +227,12 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): def _verify_response(self, name, subs, response): expected = self._read_template(name) expected = self._objectify(expected) - with file(self._get_sample(name)) as sample: - sample_data = sample.read() response_data = response.read() + try: + with file(self._get_sample(name)) as sample: + sample_data = sample.read() + except IOError: + sample_data = "{}" try: response_result = self._verify_something(subs, expected, -- cgit