3

Paverファイルで実行されるタスクを作成しようとしnosetestsています。

私のディレクトリ構造は次のようになります。

project/
   file1.py
   file2.py
   file3.py
   build/
      pavement.py
   subproject/
      file4.py
   test/
      file5.py
      file6.py

Doctests (オプションを使用) はすべての *.py ファイルで実行する必要がありますが、テスト ルーチンを検索する必要があるのは(この例ではと)--with_doctestの下のファイルのみです。project/testfile5.pyfile6.py

これを行う方法がわからないようです-nose正しいファイルを含むカスタムプラグインを作成できますが、タスクpaverを呼び出す前にビルドしてインストールすることはできません。コマンドラインでテストするファイルのリストを渡すnosetests方法も見つかりません。pavernosetests

これを機能させる最良の方法は何ですか?

4

1 に答える 1

2

これは、あなたが達成しようとしているものにまったく近いですか?

from paver.easy import sh, path
__path__ = path(__file__).abspath().dirname()

@task
def setup_nose_plugin():
    # ... do your plugin setup here.

@task
@needs('setup_nose_plugin')
def nosetests():
    nose_options = '--with-doctest' # Put your command-line options in there
    sh('nosetests %s' % nose_options, 
       # Your pavement.py is in a weird place, so you need to specify the working dir:
       cwd=__path__.parent)

特定のファイルを調べるようにノーズに指示する方法は実際にはわかりませんが、それはコマンドラインオプションの問題です。

--whereディレクトリを指定できますが、「ここでは doctests のみを実行し、ここでは他のテストを実行する」という方法がわかりません。sh('nosetests')すべてを行うには、 を2 回呼び出す必要がある場合があります。

于 2009-12-21T22:15:04.587 に答える