From c957fc5b5e5fc53f6ed8dd821373cfbed6bc51d113cb699b84e9fce648c1d7f6 Mon Sep 17 00:00:00 2001 From: f4lco Date: Thu, 23 Apr 2020 14:18:18 +0200 Subject: [PATCH] Fix exception type in test_retrieval (#7) Using json.JSONDecodeError should replace using the 'message' accessor of exceptions, which Python 3 removed. This works as long as "simplejson" is not added as project dependency, because "requests" gives preferential treatment to simplejson, which ships its own version of JSONDecodeError. --- tests/test_retrieval.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_retrieval.py b/tests/test_retrieval.py index 4421add..7eade96 100644 --- a/tests/test_retrieval.py +++ b/tests/test_retrieval.py @@ -1,5 +1,6 @@ # -*- encoding: utf-8 -*- +import json import logging import os import pytest @@ -45,9 +46,8 @@ def test_retrieval(canteen): try: menu = download_menu(params) - except ValueError as e: - if e.message == 'No JSON object could be decoded': - pytest.xfail('JSON endpoint returned garbage (issue #6)') - raise e + except json.JSONDecodeError as e: + pytest.xfail('JSON endpoint returned garbage (issue #6)') + raise e # Appease PyCharm inspection - xfail always raises feed.render_menu(menu)