doc/test_conftest.py - line 48
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | |
def test_doctest_basic(): |
|
py.magic.autopath().dirpath('conftest.py').copy(tmpdir.join('conftest.py')) |
|
xtxt = tmpdir.join('x.txt') |
xtxt.write(py.code.Source(""" |
.. |
>>> from os.path import abspath |
|
hello world |
|
>>> assert abspath |
>>> i=3 |
>>> print i |
3 |
|
yes yes |
|
>>> i |
3 |
|
end |
""")) |
config = py.test.config._reparse([xtxt]) |
session = config.initsession() |
-> session.main() |
l = session.getitemoutcomepairs(Failed) |
assert len(l) == 0 |
l = session.getitemoutcomepairs(Passed) |
l2 = session.getitemoutcomepairs(Skipped) |
assert len(l+l2) == 2 | |
test/session.py - line 63
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | |
def main(self): |
""" main loop for running tests. """ |
colitems = self.config.getcolitems() |
try: |
self.header(colitems) |
try: |
try: |
for colitem in colitems: |
-> self.runtraced(colitem) |
except KeyboardInterrupt: |
raise |
finally: |
self.footer(colitems) |
except Exit, ex: |
pass |
return self.getitemoutcomepairs(Failed) | |
test/session.py - line 84
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | |
def runtraced(self, colitem): |
if self.shouldclose(): |
raise Exit, "received external close signal" |
|
outcome = None |
colitem.startcapture() |
try: |
self.start(colitem) |
try: |
try: |
if colitem._stickyfailure: |
raise colitem._stickyfailure |
-> outcome = self.run(colitem) |
except (KeyboardInterrupt, Exit): |
raise |
except Outcome, outcome: |
if outcome.excinfo is None: |
outcome.excinfo = py.code.ExceptionInfo() |
except: |
excinfo = py.code.ExceptionInfo() |
outcome = Failed(excinfo=excinfo) |
assert (outcome is None or |
isinstance(outcome, (list, Outcome))) |
finally: |
self.finish(colitem, outcome) |
if isinstance(outcome, Failed) and self.config.option.exitfirst: |
py.test.exit("exit on first problem configured.", item=colitem) |
finally: |
colitem.finishcapture() | |
test/session.py - line 119
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | |
def run(self, colitem): |
if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): |
return |
if isinstance(colitem, py.test.collect.Item): |
colitem._skipbykeyword(self.config.option.keyword) |
res = colitem.run() |
if res is None: |
return Passed() |
elif not isinstance(res, (list, tuple)): |
raise TypeError("%r.run() returned neither " |
"list, tuple nor None: %r" % (colitem, res)) |
else: |
finish = self.startiteration(colitem, res) |
try: |
for name in res: |
obj = colitem.join(name) |
assert obj is not None |
-> self.runtraced(obj) |
finally: |
if finish: |
finish() |
return res | |
test/session.py - line 84
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | |
def runtraced(self, colitem): |
if self.shouldclose(): |
raise Exit, "received external close signal" |
|
outcome = None |
colitem.startcapture() |
try: |
self.start(colitem) |
try: |
try: |
if colitem._stickyfailure: |
raise colitem._stickyfailure |
-> outcome = self.run(colitem) |
except (KeyboardInterrupt, Exit): |
raise |
except Outcome, outcome: |
if outcome.excinfo is None: |
outcome.excinfo = py.code.ExceptionInfo() |
except: |
excinfo = py.code.ExceptionInfo() |
outcome = Failed(excinfo=excinfo) |
assert (outcome is None or |
isinstance(outcome, (list, Outcome))) |
finally: |
self.finish(colitem, outcome) |
if isinstance(outcome, Failed) and self.config.option.exitfirst: |
py.test.exit("exit on first problem configured.", item=colitem) |
finally: |
colitem.finishcapture() | |
test/session.py - line 107
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | |
def run(self, colitem): |
if self.config.option.collectonly and isinstance(colitem, py.test.collect.Item): |
return |
if isinstance(colitem, py.test.collect.Item): |
colitem._skipbykeyword(self.config.option.keyword) |
-> res = colitem.run() |
if res is None: |
return Passed() |
elif not isinstance(res, (list, tuple)): |
raise TypeError("%r.run() returned neither " |
"list, tuple nor None: %r" % (colitem, res)) |
else: |
finish = self.startiteration(colitem, res) |
try: |
for name in res: |
obj = colitem.join(name) |
assert obj is not None |
self.runtraced(obj) |
finally: |
if finish: |
finish() |
return res | |
/tmp/pytest-6/docdoctest/conftest.py - line 113
|
def run(self): |
mypath = self.fspath |
-> restcheck(py.path.svnwc(mypath)) | |
/tmp/pytest-6/docdoctest/conftest.py - line 92
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | |
def restcheck(path): |
localpath = path |
if hasattr(path, 'localpath'): |
localpath = path.localpath |
checkdocutils() |
import docutils.utils |
|
try: |
cur = localpath |
for x in cur.parts(reverse=True): |
confrest = x.dirpath('confrest.py') |
if confrest.check(file=1): |
confrest = confrest.pyimport() |
project = confrest.Project() |
_checkskip(path, project.get_htmloutputpath(path)) |
project.process(path) |
break |
else: |
|
_checkskip(path) |
-> rest.process(path) |
except KeyboardInterrupt: |
raise |
except docutils.utils.SystemMessage: |
|
py.test.fail("docutils processing failed, see captured stderr") | |
misc/rest.py - line 56
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | |
def process(txtpath, encoding='latin1'): |
""" process a textfile """ |
log("processing %s" % txtpath) |
assert txtpath.check(ext='.txt') |
if isinstance(txtpath, py.path.svnwc): |
txtpath = txtpath.localpath |
htmlpath = txtpath.new(ext='.html') |
|
|
style = txtpath.dirpath('style.css') |
if style.check(): |
stylesheet = style.basename |
else: |
stylesheet = None |
content = unicode(txtpath.read(), encoding) |
doc = convert_rest_html(content, txtpath, stylesheet=stylesheet, encoding=encoding) |
-> htmlpath.write(doc) | |
path/local/local.py - line 276
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 | |
def write(self, content, mode='wb'): |
""" write string content into path. """ |
s = str(content) |
-> f = self.open(mode) |
try: |
f.write(s) |
finally: |
f.close() | |