2012-02-19 16 views
6

と鼻のテストを実行するときにAssertionErrorが..私はPythonのテストとかなり緑んだ、これは私が間違ってやっているものになるかもしれませんPythonは:カバレッジ

私は私のテストを実行し、テストランナーは罰金とカバレッジ作品しかし、2つの間で私はアサーションエラーが発生します:

Traceback (most recent call last): 
    File "/usr/local/bin/coverage", line 9, in <module> 
    load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main 
    status = CoverageScript().command_line(argv) 
    File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line 
    self.coverage.stop() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop 
    self.collector.stop() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop 
    assert self._collectors[-1] is self 
AssertionError 

私はコマンドラインユーティリティをテストしようとしています。つまり、サブプロセス呼び出しをカバーするようにカバレッジを伝えなければならなかったということです。

カバレッジが実行されているスクリプトのカバー率を報告しているので、私はこの部分がうまく機能していると思います。しかし、私はカバレッジを取得して以来、私はAssertionErrorを取り除くことはできません。

何かが間違っていると理解していただければ幸いです。すべての私のコードはgithubの上で提供されています:

クイック実行:

cd /tmp/ && git clone git://github.com/h3/django-duke-client.git 
cd django-duke-client && chmod a+x run_tests && ./run_tests 

おかげ

更新

私は別のコンピュータ上でテストを実行したと私は同じAssertionErrorが.. Plusが新しいTypeError例外を得ました。 NoneType is not callable errorについて

... 
Ran 9 tests in 1.324s 

OK 
Traceback (most recent call last): 
    File "/usr/local/bin/coverage", line 9, in <module> 
    load_entry_point('coverage==3.5.1', 'console_scripts', 'coverage')() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 657, in main 
    status = CoverageScript().command_line(argv) 
    File "/usr/local/lib/python2.7/dist-packages/coverage/cmdline.py", line 526, in command_line 
    self.coverage.stop() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/control.py", line 389, in stop 
    self.collector.stop() 
    File "/usr/local/lib/python2.7/dist-packages/coverage/collector.py", line 262, in stop 
    assert self._collectors[-1] is self 
AssertionError 
Error in atexit._run_exitfuncs: 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs 
    func(*targs, **kargs) 
    File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function 
    info('process shutting down') 
TypeError: 'NoneType' object is not callable 
Error in sys.exitfunc: 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs 
    func(*targs, **kargs) 
    File "/usr/lib/python2.7/multiprocessing/util.py", line 284, in _exit_function 
    info('process shutting down') 
TypeError: 'NoneType' object is not callable 

Name        Stmts Miss Branch BrPart Cover Missing 
------------------------------------------------------------------------------ 
dukeclient/__init__     53  53  2  0  4% 1-93 
dukeclient/commands/__init__   41  33  6  2 26% 1-9, 12, 14-15, 17, 24-28, 34-43, 46-63 
... 

答えて

3

..再びテストが正常に実行され、カバレッジがまたしても、これらのエラーで正常に動作しているようですが、あなたを助けるかもしれないいくつかの要素の下に見つけてください。 nose-1.1.2-py2.7.egg/nose/plugins/からあなたのモジュールplugintest.py

、ライン174、一つは次の行読むことができます:

from multiprocessing import Manager 

インポートするmultiprocessing.utilパッケージを導き、そしてそれにexit関数を登録する:

atexit.register(_exit_function) 

が呼び出される前にplugintestにロードされているmultiprocessing.utilがアンロードされていると思われ、機能が確定していますところで、イオン。したがって

、あなたはsetup.pyファイルにインポートする場合:

from multiprocessing import util 

エラーが消えます。ところで

は、私は失敗したテストでいくつかの部分をコメントやコードのいくつかの行を変更する必要がありました:

  • -mコマンドが有効であるように思われません。
  • 名前を変更する必要がありましたduke_conf.ymlduke_conf.ymlです。
  • README.rstLICENSEファイルが存在するかどうかを確認するテストは失敗しています(理由を確認する時間がありません)。

希望すると、

関連する問題