[Tutor] How to use setUpmodule() variables in tests?

Steven D'Aprano steve at pearwood.info
Sat May 7 07:02:04 EDT 2016


On Fri, May 06, 2016 at 09:41:18PM -0700, ramakrishna reddy wrote:
> Dear All,
> 
> In unittesting in python, how can I use variables of setUpModule() in tests?
> 
> example:
> 
> import unittest
> 
> def setUpModule():
>     b = 20  #----> how can I use this variable in testa print

b here is a local variable. If you want it to be seen outside of the 
setUpModule function, you have to make it a global variable.



-- 
Steve


More information about the Tutor mailing list