1 """py.test hacks to support XFAIL/XPASS"""
3 # XXX this should be integrated into py.test
4 # XXX but we can't force everyone to install py-lib trunk
6 # tested with py-lib 0.9.0
7 from py
.__.test
.outcome
import Outcome
, Passed
, Failed
, Skipped
8 from py
.__.test
.terminal
.terminal
import TerminalSession
9 from time
import time
as now
19 TerminalSession
.typemap
[XFail
] = 'f'
20 TerminalSession
.typemap
[XPass
] = 'X'
22 TerminalSession
.namemap
[XFail
] = 'XFAIL'
23 TerminalSession
.namemap
[XPass
] = '*** XPASS ***'
26 def footer(self
, colitems
):
27 super(TerminalSession
, self
).footer(colitems
)
37 """report unexpectedly passed tests"""
39 for colitem
, outcome
in self
.getitemoutcomepairs(XPass
):
40 raisingtb
= self
.getlastvisible(outcome
.excinfo
.traceback
)
41 fn
= raisingtb
.frame
.code
.path
42 lineno
= raisingtb
.lineno
43 #d = texts.setdefault(outcome.excinfo.exconly(), {})
44 d
= texts
.setdefault(outcome
.msg
, {})
45 d
[(fn
,lineno
)] = outcome
49 self
.out
.sep('_', '*** XPASS ***')
50 for text
, dict in texts
.items():
51 #for (fn, lineno), outcome in dict.items():
52 # self.out.line('Skipped in %s:%d' %(fn, lineno+1))
53 #self.out.line("reason: %s" % text)
54 self
.out
.line("%s" % text
)
57 def summaryline(self
):
60 for typ
in Passed
, XPass
, XFail
, Failed
, Skipped
:
61 l
= self
.getitemoutcomepairs(typ
)
63 outlist
.append('%d %s' % (len(l
), typ
.__name
__.lower()))
65 elapsed
= self
.endtime
-self
.starttime
66 status
= "%s" % ", ".join(outlist
)
67 self
.out
.sep('=', 'tests finished: %s in %4.2f seconds' %
71 if self
.getitemoutcomepairs(Failed
):
72 self
.out
.line('DO *NOT* COMMIT!')
74 TerminalSession
.footer
= footer
75 TerminalSession
.xpasses
= xpasses
76 TerminalSession
.summaryline
= summaryline
84 raise # pass-through test outcome
86 raise XFail('XFAIL: %s' % func
.func_name
)
88 raise XPass('XPASS: %s' % func
.func_name
)