[Toaster] [PATCH 9/9] toaster: don't catch json.load exceptions
Michael Wood
michael.g.wood at intel.com
Tue Aug 11 06:07:45 PDT 2015
Thanks - Submitted upstream (with the additional patches post-rebase)
On 06/08/15 11:15, Ed Bartosh wrote:
> It doesn't make sense to catch json.load exceptions in the
> testing code. It's not a production code and if it fails
> because some API doesn't return json code it's better to
> see full traceback.
>
> Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
> ---
> bitbake/lib/toaster/toastergui/tests.py | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
> index a549a02..a38cdab 100644
> --- a/bitbake/lib/toaster/toastergui/tests.py
> +++ b/bitbake/lib/toaster/toastergui/tests.py
> @@ -21,6 +21,8 @@
>
> """Test cases for Toaster GUI and ReST."""
>
> +import json
> +
> from django.test import TestCase
> from django.core.urlresolvers import reverse
> from orm.models import Project, Release, BitbakeVersion
> @@ -69,11 +71,7 @@ class ViewTests(TestCase):
> self.assertEqual(response.status_code, 200)
> self.assertTrue(response['Content-Type'].startswith('application/json'))
>
> - try:
> - import json
> - data = json.loads(response.content)
> - except:
> - self.fail("Response %s is not json-loadable" % response.content)
> + data = json.loads(response.content)
>
> self.assertTrue("error" in data)
> self.assertEqual(data["error"], "ok")
> @@ -92,11 +90,7 @@ class ViewTests(TestCase):
> self.assertEqual(response.status_code, 200)
> self.assertTrue(response['Content-Type'].startswith('application/json'))
>
> - try:
> - import json
> - data = json.loads(response.content)
> - except:
> - self.fail("Response %s is not json-loadable" % response.content)
> + data = json.loads(response.content)
>
> self.assertTrue("error" in data)
> self.assertEqual(data["error"], "ok")
More information about the toaster
mailing list