def test_get_hashrate_inputs(mock_recv, mock_connect, hashrate_sample, outcome):
""" Ensures input values are checked and handled correctly """
# sets up the return value for socket.recv
mock_recv.return_value = str(json.dumps(STAT_EVENT_HASHRATE)+"\n").encode()
# ensures the proper output value
if isinstance(outcome, (int, float)):
assert bitcoin_computer.get_hashrate(hashrate_sample) == outcome
else:
# When raises exception when invalid input is given
with pytest.raises(outcome):
bitcoin_computer.get_hashrate(hashrate_sample)
评论列表
文章目录