[chirp_devel] [PATCH] Fix minor bugs in run_tests (#2343, #2347)
Zach Welch
Sun Mar 15 12:52:39 PDT 2015
On 03/15/2015 12:43 PM, Dan Smith wrote:
>> -# change to the tests directory
>> -scriptdir = os.path.dirname(sys.argv[0])
>> -os.chdir(scriptdir)
>> +if __name__ == "__main__":
>> + # change to the tests directory
>> + scriptdir = os.path.dirname(sys.argv[0])
>> + if scriptdir:
>> + os.chdir(scriptdir)
>
> Why protect this with the __main__ check? This is never imported from
> anywhere, so we're always in __main__ at this scope.
>
>> -logger.handle_options(LoggerOpts())
>> +if __name__ == "__main__":
>> + if not os.path.exists("logs"):
>> + os.mkdir("logs")
>> + logger.handle_options(LoggerOpts())
>
> Same.
>
> That said, with that applied, I can run tests on windows properly.
I believe that running a script via 'python <script>' causes it to first
be imported and then run. At the very least, 'pydoc run_tests' will
cause the module to be imported but it should not be run.
I don't think there's anything wrong with adding those checks, and there
are definitely situations where it's right.
--
Zach Welch
Mandolin Creek Farm
www.mandolincreekfarm.com
farm: 541-453-4131
cell: 541-740-3410
More information about the chirp_devel
mailing list