lundi 14 septembre 2015

Testing Python code that relies on hardware

So I have some code which uses gphoto2 to capture some images and stuff, I figured the best way to test this would be to wrap the gphoto2 code in something like an if TESTING: then return fake data, else do the gphoto2 stuff.

Does anyone know how I would achieve this, I've tried googling some things but I've not had any luck with specifically detecting if unit tests are being run or not.

I'd assume it would be something like if unittest: but maybe there is a better way to do this altogether?

Aucun commentaire:

Enregistrer un commentaire