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

Jan Balster jan at balster.info
Sat Mar 25 20:13:33 CET 2006


Brian Dorsey wrote:
> 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.


A list would be better, how should main() know that 'filename with spaces.py' is
one name? The shell would interpret 'filename\ with\ spaces.py' or '"filename
with spaces.py"' as one name with spaces (but we do not want to reimplement
this). We should let the shell/user(who uses main directly) do the escaping
stuff and let main work with a list.

cheers,
 jan

> 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:
> _______________________________________________
> py-dev mailing list
> py-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/py-dev
> 



More information about the Pytest-dev mailing list