2017-01-10 28 views
0

私のテストファイルと同じディレクトリレベルでconftest.pyを追加しました。私conftest.pyの内容:pytestコマンドライン引数が失敗しました

import pytest 

    def pytest_addoption(parser): 
     parser.addoption("--l", action="store", help="Get license value") 
    @pytest.fixture 
    def lic(request): 
     return request.config.getoption("--l") 

と、次は私のテストファイルデフ

def test(lic): 
     print "testing license : %s"%lic 
     assert 0 

ですが、私はまだ、次のエラーを取得:応答は、--lオプションが言うように

pytest .\source\test_latestLinuxAgent.py --l=test 
     pytest : usage: pytest [options] [file_or_dir] [file_or_dir] [...] 
     At line:1 char:1 
     + pytest .\source\test_latestLinuxAgent.py --l=test 


     pytest: error: ambiguous option: --l=test could match --lf, --last-failed 

答えて

1

をあいまいです。どういう意味ですか?

例を挙げて説明します。 --zaaaaオプションがある場合、そのショートカットは--zです。ただし、z charで始まる唯一のオプションは、--zaaaaでなければなりません。そうでなければ、インタプリタは選択すべきオプションを知らない。

--lオプションを定義することはできません。l char:--lf--last-failedで始まる2つのオプションがあるためです。

私は矛盾しないオプションを作成することをお勧めします。--licenseはすばらしいでしょう。

+0

ありがとうございました。 – user3482804

関連する問題