<div dir="ltr"><div><div>Hi,<br><br><br></div>I'm trying to create a mock wrapper around a requests Response object, so that I can check the calls to both methods and attributes, while still using the underlying Response object.<br><br></div>However I'm struggling to ensure that access of a custom dict class that is an attribute of the Response object works as expected and I'm wondering if I'm missing something or perhaps mock doesn't support my desired usage?<br><div><br>see <a href="https://gist.github.com/electrofelix/40f4c38cf28bb701dba3">https://gist.github.com/electrofelix/40f4c38cf28bb701dba3</a> for an example with some asserts that ideally should work but fails in membership tests.<br><div><br></div><div>The Response object headers attribute, is of type CaseInsensitiveDict, but there doesn't seem to be an easy way to wrap that object so that various tests for membership against the mock will work as expected. Though certain key access works correctly.<br></div><div><br><br></div><div>My first assumption is I'm doing something wrong, but it might just be a bug or missing desirable behaviour?<br clear="all"></div><div><div><br>-- <br><div>Darragh Bailey<br>"Nothing is foolproof to a sufficiently talented fool"</div>
</div></div></div></div>