[issue11955] 3.3 : test_argparse.py fails 'make test'

paul j3 report at bugs.python.org
Wed Jul 31 03:27:40 CEST 2013


paul j3 added the comment:

The test names are:

FAIL: test_failures_many_groups_listargs (__main__.TestFileTypeW)     
FAIL: test_failures_many_groups_sysargs (__main__.TestFileTypeW)      
FAIL: test_failures_no_groups_listargs (__main__.TestFileTypeW)       
FAIL: test_failures_no_groups_sysargs (__main__.TestFileTypeW)        
FAIL: test_failures_one_group_listargs (__main__.TestFileTypeW)       
FAIL: test_failures_one_group_sysargs (__main__.TestFileTypeW)    

So they differ by [many_groups, no_groups, one_group] and [listargs, sysargs]

There are about 170 tests in test_argparse that get multiplied by 6 in this way.  If this replication was removed it would cut the number of tests and time to nearly a third.

This replication is not useful.  listargs and sysargs differ only in how a list of arguments is passed to parse_args, either directly, or via sys.argv.  It should be sufficient to test these alternatives once, not 170 times.

'one group' creates an argument group, and adds all arguments to that.  'many groups' creates an argument group for each added argument.  But argument groups are not used for 'parse_args'.  They are only used when formatting help.  By default all the arguments of parser are already put into one of two groups, 'optional arguments' or 'positional arguments'.

There are tests for the help formatting, but they don't use this ParserTesterMetaclass.  

I would recommend removing this test replication.  It is both unnecessary and a source of confusion.  The simplest would be to change the end of the ParserTesterMetaclass.  

    class ParserTesterMetaclass
        def __init__()
        ....
            for add_arguments in [no_groups]:
                for parse_args in [listargs]:
                    AddTests(cls, add_arguments, parse_args)

I suspect there is some confusion among users and developers as to what argument groups do.  

As for the TestFileTypeW error, I suspect it has to do with file writing privileges.  I haven't encountered it, but I running tests in my own directory.

----------
nosy: +paul.j3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11955>
_______________________________________


More information about the Python-bugs-list mailing list