[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

testing code

On Friday, 6 July 2018 09:22:31 UTC+5:30, Chris Angelico  wrote:
> On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa
> <sharan.basappa at gmail.com> wrote:
> > Please let me know if the following understanding of mine is correct.
> > I need to put the program code in a separate file and organize every executable code in some form of function. If any code exists outside of function then it is not executable by importing.
> >
> Kinda. It's actually the other way around: if any code exists outside
> of functions, it will be executed immediately when you import. So
> you're correct in that it would be hard (maybe impossible) to
> unit-test that; and yes, the normal way to do it is to put all your
> important code into functions.
> ChrisA

thanks a lot