title: comparing dict returned by json.dumps using mock in Python
body: <p>My python tool, "Bar", has to obtain key from certain server. It uses <code>requests.post</code> method. I want to write unit test, which will check if <code>post</code> is called with correct arguments. Here is how test looks like:</p>
  
  <pre><code>@mock.patch('bar_project.bar.main.requests.post')
  def test_correct_request_call(self,
                                mock_requests_post):
  
      client = Bar.Bar(t_url, t_user_name, t_user_password)
  
      expected_call_args = ({'data': '{"password": "t_user_password", "username": "t_user_name"}',
                             'headers': {'Content-type': 'application/json'},
                             'url': 't_url/apilogin',
                             'verify': False})
  
      mock_requests_post_call_kwargs = mock_requests_post.call_args[1]
      self.assertEqual(mock_requests_post_call_kwargs, expected_call_args)
  </code></pre>
  
  <p>The thing is that there is 50% of chances that test would pass. It is not deterministic. As sometimes <code>mock_requests_post.call_args[1]</code> returns dict with <code>data</code> value:  </p>
  
  <p><code>'{"username": "t_user_name", "password": "t_user_password"}'</code><br>
  and sometimes with<br>
  <code>'{"password": "t_user_password", "username": "t_user_name"}'</code>.  </p>
  
  <p>How can I rewrite test to keep it simple but still check arguments i called <code>post</code> with?</p>