[TIP] Run-time configuration of unittest cases

Mateusz Łoskot mateusz at loskot.net
Thu Apr 24 13:30:09 PDT 2014


On 23 April 2014 23:44, Mateusz Łoskot <mateusz at loskot.net> wrote:
> My question though is more ways to pass parameters, read from file
> or read from os.env, to unittest.TestCase instances.
> For example, this looks fine:
>
> import unittest
> import myconfig
>
> config = {}
> def setUpModule():
>     config = myconfig.read() # raises if no config found

Or, simpler:

def setUpModule():
    globals()['config'] = myconfig.read()

better?

Best regards,
-- 
Mateusz  Łoskot, http://mateusz.loskot.net



More information about the testing-in-python mailing list