On Wednesday, January 11, 2017 at 10:01:58 PM UTC-5, [email protected] wrote: > > At present the code includes 'testing code' that I've used to confirm that > the various unit transformations all work, and this is controlled by a > single class boolean variable. Is it better to leave this code in there for > others to check things out or should it be removed to make the code easier > to understand? >
imho, you should keep the testing code in the driver. it will help you tremendously when someone starts using the driver in ways or environments you never expected. i've been using a "run the driver directly" pattern for this kind of testing. at the bottom of the driver file, make a __main__ section so you can invoke the driver directly like this: PYTHONPATH=/home/weewx/bin python /home/weewx/bin/user/hp1000.py --help it should have a minimal number of options. if nothing is specified, it should get data from the station and print it to stdout. there might be options for port or interface - whatever someone would have to put in the driver's stanza in weewx.conf. then you might have an option to test decoding of data or sending a broadcast message - just the basic things that you had to do to make sure you could talk to the hardware. if you put the test code there, then it will be runnable for debugging and diagnostics, but it will help keep weewx wee since the code in __main__ never loads when weewx actually runs. once again, take a look at some of the drivers i've written for examples: https://github.com/matthewwall and if you have your own clever tips and tricks, please post so we can all learn! m
