how to mock the following using MagicMock in Python 2.6.6:
with open('filename.txt', 'rb') as f:
    json.dumps(json.load(f))
how to mock the following using MagicMock in Python 2.6.6:
with open('filename.txt', 'rb') as f:
    json.dumps(json.load(f))
 
    
    Yay, I found the solution, this is my approach:
@patch("json.load", MagicMock('{cool}')
@patch("json.dumps", MagicMock(return_value='{cool}'))
 
    
    You can use mock framework (install it by pip). Use patch and mock_open by following this answer.
 
    
    