[py-dev] Re: [py-svn] r24998 - py/dist/py/test

Brian Dorsey brian at dorseys.org
Sat Mar 25 19:03:15 CET 2006


On 25/03/06, cfbolz at codespeak.net <cfbolz at codespeak.net> wrote:
> Author: cfbolz
> Date: Sat Mar 25 16:34:53 2006
> New Revision: 24998
>
> Modified:
>    py/dist/py/test/cmdline.py
> Log:
> make driving py.test programmatically easier, by allowing to not use sys.argv.
> User feature request.

I like this idea, but I wonder if it a bit less magic to expect a list
of args rather than splitting a string in main()? That way it would be
easy to modify an existing copy of sys.argv or use the args from
another option parsing library (like optparse) as well.

Take care,
  -Brian


> Modified: py/dist/py/test/cmdline.py
> ==============================================================================
> --- py/dist/py/test/cmdline.py  (original)
> +++ py/dist/py/test/cmdline.py  Sat Mar 25 16:34:53 2006
> @@ -4,9 +4,13 @@
>  # main entry point
>  #
>
> -def main():
> +def main(args=None):
>      warn_about_missing_assertion()
> -    config, args = py.test.Config.parse(py.std.sys.argv[1:])
> +    if args is None:
> +        args = py.std.sys.argv[1:]
> +    elif isinstance(args, basestring):
> +        args = args.split(" ")
> +    config, args = py.test.Config.parse(args)
>      sessionclass = config.getsessionclass()
>      session = sessionclass(config)
>      try:



More information about the Pytest-dev mailing list