This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients ezio.melotti, michael.foord, pitrou
Date 2013-02-28.12:06:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362053179.97.0.804921948739.issue17063@psf.upfronthosting.co.za>
In-reply-to
Content
Just got bitten by this again. Context: I have a protocol which is sending JSON datagrams over the wire and I'm checking the sent data. I can't exactly check the JSON-encoded content since dict ordering is undefined. So right now I have to write:

    self.assertEqual(q.transport.send.call_count, 1)
    (dgram, target), _ = q.transport.send.call_args
    self.assertEqual(target, (PEER, PORT))
    self.assertEqual(json.loads(dgram), { ... })

Clumsy, clumsy (note that I am too lazy to add a check for the kwargs).

Would be much better if I could simply write:

    dgram, = q.tranport.assert_called_once_with(mock.ANY, (PEER, PORT))
    self.assertEqual(json.loads(dgram), { ... })
History
Date User Action Args
2013-02-28 12:06:20pitrousetrecipients: + pitrou, ezio.melotti, michael.foord
2013-02-28 12:06:19pitrousetmessageid: <1362053179.97.0.804921948739.issue17063@psf.upfronthosting.co.za>
2013-02-28 12:06:19pitroulinkissue17063 messages
2013-02-28 12:06:19pitroucreate