test/testing/test_config.py - line 414
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 | |
def test_get_collector_trail_topdir_and_beyond(self): |
config = py.test.config._reparse([self.tmpdir]) |
col = config._getcollector(config.topdir) |
trail = config.get_collector_trail(col) |
assert len(trail) == 2 |
assert trail[0] == '.' |
assert trail[1] == () |
col2 = config._getcollector(trail) |
assert col2.fspath == config.topdir |
assert len(col2.listchain()) == 1 |
col3 = config._getcollector(config.topdir.dirpath()) |
py.test.raises(ValueError, |
-> "config.get_collector_trail(col3)") | |
test/raises.py - line 20
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | |
def raises(ExpectedException, *args, **kwargs): |
""" raise AssertionError, if target code does not raise the expected |
exception. |
""" |
assert args |
__tracebackhide__ = True |
if isinstance(args[0], str): |
expr, = args |
assert isinstance(expr, str) |
frame = sys._getframe(1) |
loc = frame.f_locals.copy() |
loc.update(kwargs) |
|
source = py.code.Source(expr) |
try: |
-> exec source.compile() in frame.f_globals, loc |
|
|
|
except ExpectedException: |
return py.code.ExceptionInfo() |
else: |
func = args[0] |
assert callable |
try: |
func(*args[1:], **kwargs) |
|
except ExpectedException: |
return py.code.ExceptionInfo() |
k = ", ".join(["%s=%r" % x for x in kwargs.items()]) |
if k: |
k = ', ' + k |
expr = '%s(%r%s)' %(func.__name__, args, k) |
raise ExceptionFailure(msg="DID NOT RAISE", |
expr=args, expected=ExpectedException) | |
None</build/buildd/codespeak-lib-0.9.0/py/test/raises.py:20> - line 1
|
-> config.get_collector_trail(col3) | |
test/config.py - line 250
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 | |
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:]]) | |