call site 15 for compat.optparse.make_option.check_value
test/rsession/testing/test_lsession.py - line 153
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
   def test_minus_k(self):
       if not hasattr(py.std.os, 'fork'):
           py.test.skip('operating system not supported')
       tmpdir = tmp
       tmpdir.ensure("sub3", "__init__.py")
       tmpdir.ensure("sub3", "test_some.py").write(py.code.Source("""
               def test_one(): 
                   pass
               def test_one_one():
                   assert 0
               def test_other():
                   raise ValueError(23)
               def test_two(someargs):
                   pass
           """))
       args = [str(tmpdir.join("sub3")), '-k', 'test_one']
->     config = py.test.config._reparse(args)
       lsession = LSession(config)
       allevents = []
           
       lsession.main(reporter=allevents.append, runner=box_runner)
       testevents = [x for x in allevents 
                       if isinstance(x, repevent.ReceivedItemOutcome)]
       assert len(testevents)
       passevents = [i for i in testevents if i.outcome.passed]
       failevents = [i for i in testevents if i.outcome.excinfo]
       assert len(passevents) == 1
       assert len(failevents) == 1
test/config.py - line 187
180
181
182
183
184
185
186
187
188
189
190
   def _reparse(self, args):
       """ this is used from tests that want to re-invoke parse(). """
       #assert args # XXX should not be empty
       global config_per_process
       oldconfig = py.test.config
       try:
           config_per_process = py.test.config = Config()
->         config_per_process.parse(args) 
           return config_per_process
       finally: 
           config_per_process = py.test.config = oldconfig 
test/config.py - line 48
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
   def parse(self, args): 
       """ parse cmdline arguments into this config object. 
               Note that this can only be called once per testing process. 
           """ 
       assert not self._initialized, (
               "can only parse cmdline args once per Config object")
       self._initialized = True
       adddefaultoptions(self)
       self._conftest.setinitial(args) 
       args = [str(x) for x in args]
->     cmdlineoption, args = self._parser.parse_args(args) 
       self.option.__dict__.update(vars(cmdlineoption))
       if not args:
           args.append(py.std.os.getcwd())
       self.topdir = gettopdir(args)
       self.args = args 
compat/optparse.py - line 1277
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
   def parse_args(self, args=None, values=None):
       """
           parse_args(args : [string] = sys.argv[1:],
                      values : Values = None)
           -> (values : Values, args : [string])
   
           Parse the command-line options found in 'args' (default:
           sys.argv[1:]).  Any errors result in a call to 'error()', which
           by default prints the usage message to stderr and calls
           sys.exit() with an error message.  On success returns a pair
           (values, args) where 'values' is an Values instance (with all
           your option values) and 'args' is the list of arguments left
           over after parsing options.
           """
       rargs = self._get_args(args)
       if values is None:
           values = self.get_default_values()
   
       # Store the halves of the argument list as attributes for the
       # convenience of callbacks:
       #   rargs
       #     the rest of the command-line (the "r" stands for
       #     "remaining" or "right-hand")
       #   largs
       #     the leftover arguments -- ie. what's left after removing
       #     options and their arguments (the "l" stands for "leftover"
       #     or "left-hand")
       self.rargs = rargs
       self.largs = largs = []
       self.values = values
   
       try:
->         stop = self._process_args(largs, rargs, values)
       except (BadOptionError, OptionValueError), err:
           self.error(err.msg)
   
       args = largs + rargs
       return self.check_values(values, args)
compat/optparse.py - line 1321
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
   def _process_args(self, largs, rargs, values):
       """_process_args(largs : [string],
                            rargs : [string],
                            values : Values)
   
           Process command-line arguments and populate 'values', consuming
           options and arguments from 'rargs'.  If 'allow_interspersed_args' is
           false, stop at the first non-option argument.  If true, accumulate any
           interspersed non-option arguments in 'largs'.
           """
       while rargs:
           arg = rargs[0]
           # We handle bare "--" explicitly, and bare "-" is handled by the
           # standard arg handler since the short arg case ensures that the
           # len of the opt string is greater than 1.
           if arg == "--":
               del rargs[0]
               return
           elif arg[0:2] == "--":
               # process a single long option (possibly with value(s))
               self._process_long_opt(rargs, values)
           elif arg[:1] == "-" and len(arg) > 1:
               # process a cluster of short options (possibly with
               # value(s) for the last one only)
->             self._process_short_opts(rargs, values)
           elif self.allow_interspersed_args:
               largs.append(arg)
               del rargs[0]
           else:
               return                  # stop now, leave this arg in rargs
compat/optparse.py - line 1428
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
   def _process_short_opts(self, rargs, values):
       arg = rargs.pop(0)
       stop = False
       i = 1
       for ch in arg[1:]:
           opt = "-" + ch
           option = self._short_opt.get(opt)
           i += 1                      # we have consumed a character
   
           if not option:
               self.error(_("no such option: %s") % opt)
           if option.takes_value():
               # Any characters left in arg?  Pretend they're the
               # next arg, and stop consuming characters of arg.
               if i < len(arg):
                   rargs.insert(0, arg[i:])
                   stop = True
   
               nargs = option.nargs
               if len(rargs) < nargs:
                   if nargs == 1:
                       self.error(_("%s option requires an argument") % opt)
                   else:
                       self.error(_("%s option requires %d arguments")
                                  % (opt, nargs))
               elif nargs == 1:
                   value = rargs.pop(0)
               else:
                   value = tuple(rargs[0:nargs])
                   del rargs[0:nargs]
   
           else:                       # option doesn't take a value
               value = None
   
->         option.process(opt, value, values, self)
   
           if stop:
               break
compat/optparse.py - line 704
700
701
702
703
704
705
706
707
708
709
710
   def process(self, opt, value, values, parser):
   
       # First, convert the value(s) to the right type.  Howl if any
       # value(s) are bogus.
->     value = self.convert_value(opt, value)
   
       # And then take whatever action is expected of us.
       # This is a separate method to make life easier for
       # subclasses to add new actions.
       return self.take_action(
           self.action, self.dest, opt, value, values, parser)
compat/optparse.py - line 696
693
694
695
696
697
698
   def convert_value(self, opt, value):
       if value is not None:
           if self.nargs == 1:
->             return self.check_value(opt, value)
           else:
               return tuple([self.check_value(opt, v) for v in value])