Movatterモバイル変換
[0]ホーム
excluding unit test code
Steven Haryantosteven at haryan.to
Tue Apr 3 09:56:51 EDT 2001
At 4/3/2001 06:54 AM, you wrote: > What do you mean by "exclude"?The same way -OO excludes doc-string from the sourcecode, i.e.: it is optimized away by the compiler,and never gets into the object code/loaded intomemory/executed. > If this were C, > I'd say that you could just use "#if 0" around the > test blocks for when you ship production code. > The quick way is to convert: > > some_test_code() > > into > > if None: > some_test_code() > > if that's OK with you. That way it will never be > executed. How else you would do it depends on your > definition of "excluded". You could hide it in > another module, or just cut it out altogether.After being advised by Steve Purcell, I think I will gowith something like 'if __DEBUG__' instead of 'if 0' or'#if DEBUG' (running the Python source through cppfirst), so clients _can_ execute the test code.Thanks,Steve
More information about the Python-listmailing list
[8]ページ先頭