File tree 2 files changed +10
-10
lines changed 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -655,20 +655,17 @@ def _set_opt_strings(self, opts):
655
655
self ._long_opts .append (opt )
656
656
657
657
def __repr__ (self ):
658
- retval = 'Argument('
658
+ args = []
659
659
if self ._short_opts :
660
- retval += '_short_opts: ' + repr (self ._short_opts ) + ', '
660
+ args += [ '_short_opts: ' + repr (self ._short_opts )]
661
661
if self ._long_opts :
662
- retval += '_long_opts: ' + repr (self ._long_opts ) + ', '
663
- retval += 'dest: ' + repr (self .dest ) + ', '
662
+ args += [ '_long_opts: ' + repr (self ._long_opts )]
663
+ args += [ 'dest: ' + repr (self .dest )]
664
664
if hasattr (self , 'type' ):
665
- retval += 'type: ' + repr (self .type ) + ', '
665
+ args += [ 'type: ' + repr (self .type )]
666
666
if hasattr (self , 'default' ):
667
- retval += 'default: ' + repr (self .default ) + ', '
668
- if retval [- 2 :] == ', ' : # always long enough to test ("Argument(" )
669
- retval = retval [:- 2 ]
670
- retval += ')'
671
- return retval
667
+ args += ['default: ' + repr (self .default )]
668
+ return 'Argument({0})' .format (', ' .join (args ))
672
669
673
670
674
671
class OptionGroup :
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ def test_argument(self):
29
29
assert argument .dest == 'test'
30
30
argument = parseopt .Argument ('-t' , '--test' , dest = 'abc' )
31
31
assert argument .dest == 'abc'
32
+ assert str (argument ) == (
33
+ "Argument(_short_opts: ['-t'], _long_opts: ['--test'], dest: 'abc')"
34
+ )
32
35
33
36
def test_argument_type (self ):
34
37
argument = parseopt .Argument ('-t' , dest = 'abc' , type = 'int' )
You can’t perform that action at this time.
0 commit comments