my module and unittest contend over commandline options...

chrisber christophberendes at gmail.com
Fri May 2 16:06:42 EDT 2008


On May 2, 4:54 am, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> chrisber<christophberen... at gmail.com> wrote:
> > ...it leaves me
> > wonderfing whether there would have been another clean way to allow
> > both my test code and unittest to have options without interfering
> > with one another.
>
> You can pass argv as a parameter to main(), so I think the best bet is
> simply to build up a new argv with the options that you want to pass
> through.

Aha! I scanned through my python 2.4 installataion and found this in
unittest
  def __init__(self, module='__main__', defaultTest=None,
                 argv=None, testRunner=None,
testLoader=defaultTestLoader):
        if type(module) == type(''):
            self.module = __import__(module)
            for part in module.split('.')[1:]:
                self.module = getattr(self.module, part)
        else:
            self.module = module
        if argv is None:
            argv = sys.argv

so I see what you mean. Thanks.




More information about the Python-list mailing list