call site 2 for test.config.addoptions
test/testing/test_config.py - line 30
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
   def test_config_cmdline_options(): 
       o = py.test.ensuretemp('configoptions') 
       o.ensure("conftest.py").write(py.code.Source(""" 
           import py
           def _callback(option, opt_str, value, parser, *args, **kwargs):
               option.tdest = True
           Option = py.test.config.Option
           option = py.test.config.addoptions("testing group", 
               Option('-G', '--glong', action="store", default=42,
                      type="int", dest="gdest", help="g value."), 
               # XXX note: special case, option without a destination
               Option('-T', '--tlong', action="callback", callback=_callback,
                       help='t value'),
               )
           """))
       old = o.chdir() 
       try: 
->         config = py.test.config._reparse(['-G', '17'])
       finally: 
           old.chdir() 
       assert config.option.gdest == 17 
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 46
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 
test/conftesthandle.py - line 32
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
   def setinitial(self, args):
       """ return a Conftest object initialized with a path obtained
               from looking at the first (usually cmdline) argument that points
               to an existing file object. 
               XXX note: conftest files may add command line options
               and we thus have no completely safe way of determining
               which parts of the arguments are actually related to options. 
           """
       current = py.path.local()
       for arg in args + [current]:
           anchor = current.join(arg, abs=1)
           if anchor.check(): # we found some file object 
               #print >>py.std.sys.stderr, "initializing conftest from", anchor
               # conftest-lookups without a path actually mean 
               # lookups with our initial path. 
->             self._path2confmods[None] = self.getconftestmodules(anchor)
               #print " -> ", conftest._path2confmods
               break
test/conftesthandle.py - line 48
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
   def getconftestmodules(self, path):
       """ return a list of imported conftest modules for the given path.  """ 
       try:
           clist = self._path2confmods[path]
       except KeyError:
           dp = path.dirpath()
           if dp == path: 
               return [importconfig(defaultconftestpath)]
           clist = self.getconftestmodules(dp)
           conftestpath = path.join("conftest.py")
           if conftestpath.check(file=1):
->             clist.append(importconfig(conftestpath))
           self._path2confmods[path] = clist
       # be defensive: avoid changes from caller side to
       # affect us by always returning a copy of the actual list 
       return clist[:]
test/conftesthandle.py - line 76
68
69
70
71
72
73
74
75
76
77
78
79
   def importconfig(configpath):
       # We could have used caching here, but it's redundant since
       # they're cached on path anyway, so we use it only when doing rget_path
       assert configpath.check(), configpath
       if not configpath.dirpath('__init__.py').check(file=1): 
           # HACK: we don't want any "globally" imported conftest.py, 
           #       prone to conflicts and subtle problems 
           modname = str(configpath).replace('.', configpath.sep)
->         mod = configpath.pyimport(modname=modname)
       else:
           mod = configpath.pyimport()
       return mod
path/local/local.py - line 429
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
   def pyimport(self, modname=None, ensuresyspath=True):
       """ return path as an imported python module.
               if modname is None, look for the containing package
               and construct an according module name.
               The module will be put/looked up in sys.modules.
           """
       if not self.check():
           raise py.error.ENOENT(self)
       #print "trying to import", self
       pkgpath = None
       if modname is None:
           #try:
           #    return self._module
           #except AttributeError:
           #    pass
           pkgpath = self.pypkgpath()
           if pkgpath is not None:
               if ensuresyspath:
                   self._prependsyspath(pkgpath.dirpath())
               pkg = __import__(pkgpath.basename, None, None, [])
                   
               if hasattr(pkg, '__pkg__'):
                   modname = pkg.__pkg__.getimportname(self)
                   assert modname is not None, "package %s doesn't know %s" % (
                                               pkg.__name__, self)
                   
               else:
                   names = self.new(ext='').relto(pkgpath.dirpath())
                   names = names.split(self.sep)
                   modname = ".".join(names)
           else:
               # no package scope, still make it possible
               if ensuresyspath:
                   self._prependsyspath(self.dirpath())
               modname = self.purebasename
           mod = __import__(modname, None, None, ['__doc__'])
           #self._module = mod
           return mod
       else:
           try:
               return sys.modules[modname]
           except KeyError:
               # we have a custom modname, do a pseudo-import
               mod = py.std.new.module(modname)
               mod.__file__ = str(self)
               sys.modules[modname] = mod
               try:
->                 execfile(str(self), mod.__dict__)
               except:
                   del sys.modules[modname]
                   raise
               return mod
/tmp/pytest-7/configoptions/conftest.py - line 11
2
3
4
5
    
   import py
   def _callback(option, opt_str, value, parser, *args, **kwargs):
       option.tdest = True