From 183a53e3be74fabf501eaff19a39a47f1a6c9af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 17 Jan 2018 02:43:28 +0100 Subject: Write some tests for Portfolio class --- portfolio.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'portfolio.py') diff --git a/portfolio.py b/portfolio.py index 507f796..a4fbf94 100644 --- a/portfolio.py +++ b/portfolio.py @@ -32,8 +32,14 @@ class Portfolio: urllib3.disable_warnings() http = urllib3.PoolManager() - r = http.request("GET", cls.URL) - cls.data = json.loads(r.data) + try: + r = http.request("GET", cls.URL) + except Exception: + return + try: + cls.data = json.loads(r.data) + except json.JSONDecodeError: + cls.data = None @classmethod def parse_cryptoportfolio(cls): -- cgit v1.2.3