From fecf3e81c41fb56ec79ae8c2e51027a35b50a7f6 Mon Sep 17 00:00:00 2001 From: Makaze Date: Sun, 20 Oct 2024 14:22:12 -0400 Subject: [PATCH] fix: allow any args to mocked request --- bitcoin/testing.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bitcoin/testing.py b/bitcoin/testing.py index f1ddf71e..58f00564 100644 --- a/bitcoin/testing.py +++ b/bitcoin/testing.py @@ -1,28 +1,29 @@ -class FakeResponse(): - +class FakeResponse: def __init__(self): self.status_code = 200 self.text = '{"bpi":{"USD":{"code":"USD","symbol": "$","rate":"37,817.3283","description":"United States Dollar","rate_float": 37817.3283}}}' def json(*args): return { - "bpi": { - "USD": { - "code": "USD", - "symbol": "$", - "rate": "37,817.3283", - "description": "United States Dollar", - "rate_float": 37817.3283 - } + "bpi": { + "USD": { + "code": "USD", + "symbol": "$", + "rate": "37,817.3283", + "description": "United States Dollar", + "rate_float": 37817.3283, } } - + } + # Mock raise_for_status def raise_for_status(self): pass + import requests -requests.get = lambda x, *args, **kwargs: FakeResponse() + +requests.get = lambda *args, **kwargs: FakeResponse() # Run bitcoin via import import bitcoin @@ -33,4 +34,4 @@ def raise_for_status(self): except AttributeError: # Bitcoin has no main function - pass \ No newline at end of file + pass