Mock urlilb+json in Python
Question: looking for a way to correctly mock this piece of code:

    
    
    import json
    from urllib import urlopen
    
    a_url = "http://blabla"
    my_response= urlopen(a_url)
    a_dict = json.loads(my_response.read())
    

It reads from an URL, then the response uses json.loads to store everything in
a dict. Ideas?


Answer: `urlopen` should return a mock object where `.read()` returns a string
containing JSON, e.g. `'{"a": "b"}'`.

Then throw it all away and use `requests`.

