From c877f6db0060474e503f8dd9d5238a559dff67ea Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 22 Apr 2015 21:10:19 -0400 Subject: [PATCH] Simulator should occasionally throw errors This lets me test LED blinking code. Signed-off-by: Anna Schumaker --- simulator/urllib/request.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/simulator/urllib/request.py b/simulator/urllib/request.py index 711866c..ba5f258 100644 --- a/simulator/urllib/request.py +++ b/simulator/urllib/request.py @@ -13,10 +13,12 @@ class Request: pass def read(self): - if random.randint(0, 1) == 0: + val = random.randint(0, 2) + if val == 0: return "OK".encode() - return "ERROR".encode() - + elif val == 1: + return "ERROR".encode() + raise Exception('Test Exception') def urlopen(url):