class instance of Config():
central hub for dealing with configuration/initialization data.
no source available
class attributes and properties:
args: ['/build/buildd/codespeak-lib-0.9.1/py']
option: <CmdOptions {'nocapture': False, 'verbose': 0, 'apigen': '/build/buildd/codespeak-lib-0.9.1/py/apige...
topdir: /build/buildd/codespeak-lib-0.9.1
methods:
def __init__(self):
*no docstring available*
arguments:
- self: <Instance of Class Config>
return value:
<None>
source: test/config.py
|
def __init__(self): |
self.option = CmdOptions() |
self._parser = optparse.OptionParser( |
usage="usage: %prog [options] [query] [filenames of tests]") |
self._conftest = Conftest() |
self._initialized = False | |
def addoptions(self, groupname, *specs):
add a named group of options to the current testing session.
This function gets invoked during testing session initialization.
arguments:
- self: <Instance of Class Config>
- groupname: <String>
return value:
AnyOf(<None>, <Instance of Class CmdOptions>)
source: test/config.py
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | |
def addoptions(self, groupname, *specs): |
""" add a named group of options to the current testing session. |
This function gets invoked during testing session initialization. |
""" |
for spec in specs: |
for shortopt in spec._short_opts: |
if not shortopt.isupper(): |
raise ValueError( |
"custom options must be capital letter " |
"got %r" %(spec,) |
) |
return self._addoptions(groupname, *specs) | |
def get_collector_trail(self, collector):
provide a trail relative to the topdir,
which can be used to reconstruct the
collector (possibly on a different host
starting from a different topdir).
arguments:
return value:
AnyOf(<None>, <Tuple>)
source: test/config.py
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 | |
def get_collector_trail(self, collector): |
""" provide a trail relative to the topdir, |
which can be used to reconstruct the |
collector (possibly on a different host |
starting from a different topdir). |
""" |
chain = collector.listchain() |
relpath = chain[0].fspath.relto(self.topdir) |
if not relpath: |
if chain[0].fspath == self.topdir: |
relpath = "." |
else: |
raise ValueError("%r not relative to %s" |
%(chain[0], self.topdir)) |
return relpath, tuple([x.name for x in chain[1:]]) | |
def getcolitems(self):
return initial collectors.
arguments:
- self: <Instance of Class Config>
return value:
<List>
source: test/config.py
|
def getcolitems(self): |
""" return initial collectors. """ |
trails = getattr(self, '_coltrails', None) |
return [self._getcollector(path) for path in (trails or self.args)] | |
def getvalue(self, name, path=None):
return 'name' value looked up from the 'options'
and then from the first conftest file found up
the path (including the path itself).
if path is None, lookup the value in the initial
conftest modules found during command line parsing.
arguments:
- self: <Instance of Class Config>
- name: <String>
- path: AnyOf(<Instance of Class LocalPath>, <None>)
return value:
AnyOf(<String>, <Int>,
Class Module, Class Directory, <List>, <None>, <Instance of Class object>,
Class Directory, Class Function, Class Directory, Class Instance, <Boolean>,
Class Instance,
Class Generator,
Class Function,
Class DoctestFile, Class Module, Class Directory, Class Class,
Class Class, Class DocDirectory)
source: test/config.py
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 | |
def getvalue(self, name, path=None): |
""" return 'name' value looked up from the 'options' |
and then from the first conftest file found up |
the path (including the path itself). |
if path is None, lookup the value in the initial |
conftest modules found during command line parsing. |
""" |
try: |
return getattr(self.option, name) |
except AttributeError: |
return self._conftest.rget(name, path) | |
def getvalue_pathlist(self, name, path=None):
return a matching value, which needs to be sequence
of filenames that will be returned as a list of Path
objects (they can be relative to the location
where they were found).
arguments:
- self: <Instance of Class Config>
- name: <String>
- path: <None>
return value:
AnyOf(<List>, <None>)
source: test/config.py
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | |
def getvalue_pathlist(self, name, path=None): |
""" return a matching value, which needs to be sequence |
of filenames that will be returned as a list of Path |
objects (they can be relative to the location |
where they were found). |
""" |
try: |
return getattr(self.option, name) |
except AttributeError: |
try: |
mod, relroots = self._conftest.rget_with_confmod(name, path) |
except KeyError: |
return None |
modpath = py.path.local(mod.__file__).dirpath() |
return [modpath.join(x, abs=True) for x in relroots] | |
def initsession(self):
return an initialized session object.
arguments:
- self: <Instance of Class Config>
return value:
AnyOf(<None>, <Instance of Class TerminalSession>, <Instance of Class RSession>, <Instance of Class LSession>, <Instance of Class MySession>)
source: test/config.py
|
def initsession(self): |
""" return an initialized session object. """ |
cls = self._getsessionclass() |
session = cls(self) |
session.fixoptions() |
return session | |
def parse(self, args):
parse cmdline arguments into this config object.
Note that this can only be called once per testing process.
arguments:
- self: <Instance of Class Config>
- args: <List>
return value:
<None>
source: test/config.py
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | |
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 | |