5

私は鼻でテスト スーツを書いています。

「失敗しました: is_even(5): 偶数ではありません」

デフォルトの出力の代わりに:

======================================================================
FAIL: seed_db.test_generator(5,)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/apurcell/tests/prism/seed_db.py", line 59, in is_even
    nose.tools.eq_(x % 2, 0, msg="Not even")
  File "/usr/local/lib/python2.7/dist-packages/nose/tools.py", line 31, in eq_
    assert a == b, msg or "%r != %r" % (a, b)
    AssertionError: Not even

----------------------------------------------------------------------

これを行うことができる鼻のオプションはありますか?

4

3 に答える 3

3

鼻の動作を変更したい場合は、プラグインを作成する必要があります ( API ドキュメントはこちらを参照してください)。あなたの場合、エラーが報告される方法を変更したいように聞こえるので、formatError()formatFailure(). おそらく、(行番号を含めるために) 例外メッセージを編集し、トレースバックのサイズを制限したいと思うでしょう。

于 2012-12-18T07:51:05.510 に答える
1

次の出力は、希望するものと似ていますが、同一ではありません (また、成功したテスト出力が変更されます。これは、希望するものではない可能性があります)。通常の unittest 出力の代わりに、tap.py を使用して TAP (test any protocol) を出力します。

nosetests --with-tap --tap-stream testcases-rsysflow.py

出力は次のようになります。

bjb@rhino$ nosetests testcases-rrrr.py --with-tap --tap-stream
# TAP results for TestThing
ok 1 - test_create_and_get (testcases-rrrr.TestThing)
ok 2 - test_del_one (testcases-rrrr.TestThing)
ok 3 - test_get_all (testcases-rrrr.TestThing)
not ok 4 - test_get_not_exist (testcases-rrrr.TestThing)
ok 5 - test_get_wrong_indir (testcases-rrrr.TestThing)
ok 6 - test_replace_and_get (testcases-rrrr.TestThing)
ok 7 - test_set_should_fail (testcases-rrrr.TestThing)
1..7

Test Anything Protocol (この特定の実装ではなく、プロトコルについて話している) を使用すると、エラーのダッシュの後に診断情報を出力できますが、この実装でそれを行う方法がわかりません。

この実装は便利でした。なぜなら、tap.py ( pip install tap.py) をインストールし、それらの 2 つのコマンドライン引数を、ユニットテスト テストのノーズテスト呼び出しと、poof - TAP 形式の出力に配置するだけだったからです。これを Jenkins にプラグインできます。

于 2015-07-08T13:58:10.553 に答える