我正在尝试在 Jython 上使用 pytest。我一开始就被卡住了。
我已经使用 easy_install 成功安装了 pytest 包:
$ ./jython easy_install pytest
当我尝试从此页面运行示例时,出现问题。我收到了一份非常长的故障报告,如下所示。有人知道为什么会这样吗?
py.test-jython
============================= 测试开始================== ============ 平台 java1.6.0_37 -- Python 2.5.3 -- pytest-2.3.2 收集到 1 项
test_sample.py F
==================================== 失败============== ===================== _ __ _ __ _ __ _ __ _ __ _ _ test_answer _ __ _ __ _ __ _ __ _ __ _ __
def test_answer():
assert func(3) == 5
test_sample.py:5:
自我 = 断言错误()
def __init__(self, *args):
BuiltinAssertionError.__init__(self, *args)
if args:
try:
self.msg = str(args[0])
except py.builtin._sysex:
raise
except:
self.msg = "<[broken __repr__] %s at %0xd>" %(
args[0].__class__, id(args[0]))
else:
f = py.code.Frame(sys._getframe(1))
try:
source = f.code.fullsource
if source is not None:
try:
source = source.getstatement(f.lineno, assertion=True)
except IndexError:
source = None
else:
source = str(source.deindent()).strip()
except py.error.ENOENT:
source = None
# this can also occur during reinterpretation, when the
# co_filename is set to "<run>".
if source:
self.msg = reinterpret(source, f, should_fail=True)
../jython2.5.3/Lib/site-packages/pytest-2.3.2-py2.5.egg/_pytest/assertion/reinterpret.py:32:
源 = 'assert func(3) == 5', frame = should_fail = True
def interpret(source, frame, should_fail=False):
mod = ast.parse(source)
visitor = DebugInterpreter(frame)
try:
visitor.visit(mod)
../jython2.5.3/Lib/site-packages/pytest-2.3.2-py2.5.egg/_pytest/assertion/newinterpret.py:49:
. . .
self = <_pytest.assertion.newinterpret.DebugInterpreter object at 0x4> name = Name
def visit_Name(self, name):
explanation, result = self.generic_visit(name)
../jython2.5.3/Lib/site-packages/pytest-2.3.2-py2.5.egg/_pytest/assertion/newinterpret.py:147:
self = <_pytest.assertion.newinterpret.DebugInterpreter object at 0x4> node = Name
def generic_visit(self, node):
# Fallback when we don't have a special implementation.
if _is_ast_expr(node):
mod = ast.Expression(node)
co = self._compile(mod)
try:
result = self.frame.eval(co)
except Exception:
raise Failure()
explanation = self.frame.repr(result)
return explanation, result
elif _is_ast_stmt(node):
mod = ast.Module([node])
co = self._compile(mod, "exec")
try:
self.frame.exec_(co)
except Exception:
raise Failure()
return None, None
else:
raise AssertionError("can't handle %s" %(node,))
E AssertionError: 无法处理名称
../jython2.5.3/Lib/site-packages/pytest-2.3.2-py2.5.egg/_pytest/assertion/newinterpret.py:134: AssertionError ============= ============= 1 在 0.55 秒内失败 ===========================