Python assertIn test statement not finding string?
<p>I am using <code>assertIn</code> to test that a part of the result in JSON string is correct.</p>

<pre><code>test_json = some_function_returning_a_dict()
self.assertIn(expected_json, test_json, "did not match expected output")
</code></pre>

<p>The error is</p>

<blockquote>
  <p>AssertionError: "'abc': '1.0012'," not found in [{'abc': '1.0012',...</p>
</blockquote>

<p>I used <code>Ctrl + F</code> over the inner string, and it was in the resulting string.<br>
 I'm using Python 3.0</p>

<p>Right.  Python's <strong>in</strong> operator works on an iterable object.  The clause <strong>in test_json</strong> means, "is the given item a key of the dictionary".  It does <em>not</em> search the dictionary for a <em>key:value</em> pair.</p>

<p>To do this, use a two-step process:</p>

<pre><code>assertIn('abc', test_json)
assertEquals('1.0012', test_json['abc'])
</code></pre>

<p>Doing this with appropriate variables and references is left as an exercise for the student.  :-)</p>

python python-3.x