call site 0 for compat.optparse.Option.take_action
test/testing/test_config.py - line 235
228
229
230
231
232
233
234
235
236
237
   def test_sessionname_lookup_custom(self):
       self.tmpdir.join("conftest.py").write(py.code.Source("""
               from py.__.test.session import Session
               class MySession(Session):
                   def __init__(self, config):
                       self.config = config 
           """)) 
->     config = py.test.config._reparse(["--session=MySession", self.tmpdir])
       session = config.initsession()
       assert session.__class__.__name__ == 'MySession'
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 1317
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 1392
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
   def _process_long_opt(self, rargs, values):
       arg = rargs.pop(0)
   
       # Value explicitly attached to arg?  Pretend it's the next
       # argument.
       if "=" in arg:
           (opt, next_arg) = arg.split("=", 1)
           rargs.insert(0, next_arg)
           had_explicit_value = True
       else:
           opt = arg
           had_explicit_value = False
   
       opt = self._match_long_opt(opt)
       option = self._long_opt[opt]
       if option.takes_value():
           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]
   
       elif had_explicit_value:
           self.error(_("%s option does not take a value") % opt)
   
       else:
           value = None
   
->     option.process(opt, value, values, self)
compat/optparse.py - line 710
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)