4

Jythonでpytestを使用しようとしています。そして、私は最初から立ち往生しています。

easy_install を使用して pytest パッケージを正常にインストールしました。

$ ./jython easy_install pytest

このページから例を実行しようとすると、問題が発生します。以下のような非常に長い失敗レポートを受け取りました。なぜこれが起こっているのか誰にも分かりますか?

py.test-jython

============================ テストセッション開始 ================= ============ platform 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:


source = 'assert func(3) == 5', フレーム = 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 = 名前

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> ノード = 名前

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 ============== ============= 0.55 秒で 1 件失敗 ==========================

4

2 に答える 2

4

Pytest には、jython の欠けている AST 実装に対する回避策があります。 issue1479を参照してください。pytest 側の回避策を拡張して、jython-2.5.3 で動作するようにしました。次のコマンドを使用して、pytest の開発候補をインストールできます。

pip install -i http://pypi.testrun.org -U pytest

「py.test-jython --version」で少なくともバージョン 2.3.4.dev1 を取得し、jython-2.5.3 で動作するアサーションを取得する必要があります。

于 2012-11-07T09:08:05.530 に答える
2

現在、pytest は Jython2.5.3 をサポートしておらず、Jython2.5.1 でのみ動作します。

于 2012-11-07T07:55:43.463 に答える