Fix SLO test with old simplejson

Our requirements.txt contains "simplejson>=2.0.9". With that version,
attempting to decode invalid JSON raises ValueError, not
simplejson.JSONDecodeError. In fact, there is no such thing as
JSONDecodeError; it isn't introduced until a later version. Also,
stdlib's json module doesn't have a JSONDecodeError either. However,
JSONDecodeError inherits from ValueError, so we can just catch that
instead.

Also added a better failure message when invalid JSON is detected;
we'll now fail immediately instead of later in some assertEqual().

Change-Id: I7f0db20b2d72e89c961cb43daa6888ecd878f769
This commit is contained in:
Samuel Merritt 2014-06-12 16:51:28 -07:00
parent 99cd1ff163
commit 12b81b2e61

@ -821,8 +821,8 @@ class TestSloGetManifest(SloTestCase):
headers)
try:
resp_data = json.loads(body)
except json.JSONDecodeError:
resp_data = None
except ValueError:
self.fail("Invalid JSON in manifest GET: %r" % body)
self.assertEqual(
resp_data,