[Ironpython-users] Working Directory

Slide slide.o.mix at gmail.com
Fri Aug 26 18:54:38 CEST 2011


On Fri, Aug 26, 2011 at 9:40 AM, Paul Grenyer <paul.grenyer at gmail.com>wrote:

> Hi
>
> > What does your if __name__ == "__main__": look like? Or, if you don't
> have
> > that, can you share your entry script?
>
> Yep:
>
> if __name__ == '__main__':
>        unittest.main()
>
> --
> Thanks
> Paul
>
>

You'd probably want to add something to swallow the argument and set the
working directory, otherwise the unittest module things that is the module
you want to test (look at the docs for unittest and command line arguments).
It's not an IronPython issue at all, it's unittest doing what it is supposed
to do. Inside unittest.main it pulls out the command line parameters and
uses them to determine what unittests to run.

You could do something like (not tested):

import os, sys

if __name__ == '__main__':
     os.chdir(sys.argv[1])
     del(sys.argv[1])
     unittest.main()


slide



-- 
slide-o-blog
http://slide-o-blog.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20110826/49023e27/attachment.html>


More information about the Ironpython-users mailing list