2016-12-28 3 views
5

pytestを使用してプロジェクトをテストし、デフォルトで--doctest-modulesを有効にして、プロジェクト全体からすべてのDoctestを収集しました。pytest doctestモジュールでファイルを無視できますか?

しかし、テストコレクション中にインポートされないかもしれないwsgi.pyがありますが、pytestを無視して無視します。

conftest.pycollect_ignoreリストに入れてみましたが、明らかにdoctestモジュールはこのリストを使用していません。

wsgi.pyというディレクトリ全体をpytest設定ファイルのnorecursedirsに入れているだけですが、これは明らかにディレクトリ全体を隠してしまいます。

doctestモジュールを特定のファイルだけ無視する方法はありますか?

答えて

2

フックを使用して、一部のフォルダをテスト検出から条件付きで除外することができます。 https://docs.pytest.org/en/latest/writing_plugins.html

def pytest_ignore_collect(path, config): 
    """ return True to prevent considering this path for collection. 
    This hook is consulted for all files and directories prior to calling 
    more specific hooks. 
    """ 
関連する問題