Re: [Tutor] Query regarding Unittest module behaviour

2006-07-04 Thread Luke Paireepinart
[snip]
> Script abc.py imports xyz.py.
> Now when I execute abc.py from commandlline all unittestcases of 
> xyz.py are also executed.
> Why is this happening and what can be the solution to this.
anything that's in the global scope  of an imported module gets executed.
For example...

-- a.py
print "hello"


 >>> import a
This will cause the "hello" to be printed from 'a.py' because it's in 
the global scope.
so what you want to do is something like this:

-a.py

def main():
print "hello"

if __name__ == "__main__":
main()
---

Now if you do
 >>> import a
nothing will be printed.

But, if you do "python a.py" on command line, you'll see "hello" be printed.
I think this is the problem you're having.
HTH,
-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Query regarding Unittest module behaviour

2006-07-04 Thread Akanksha Govil
Hi,I have 2 scripts , abc.py and xyz.py, In both I have made unittest cases using the unittest module.Script abc.py imports xyz.py.Now when I execute abc.py from commandlline all unittestcases of xyz.py are also executed. Why is this happening and what can be the solution to this.Also I have tried commenting the unittest.main() in xyz.py, but all in vain.Please helpAkanksha __Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor