I take as input a block of binary data (1300 bytes long), parses that (with struct), and returns a Python object with the various fields represented in that binary data.
I've been asked to write some unit tests for this object, and I'm stumped as to how to do this effectively. Our testing methodology doesn't allow for external files, so feeding it a "known good" packet to make sure fields are getting populated correctly isn't an option.
I've done some work with the mock library, and think that patch and sentinel are steps in the right direction, but I'm still running into an impasse.
It seems unreasonable that the testing fixture should have a manually-constructed (using sentinels or otherwise) data structure of hundreds of fields for testing.
Any insight or hints would be welcome.
Aucun commentaire:
Enregistrer un commentaire