2017-06-07 15 views
0

按照pytest文檔,我應該能夠使用「和」表達這樣的:pytest -k標誌與聲明和

pytest -k stringexpr # only run tests with names that match the 
        # "string expression", e.g. "MyClass and not method" 
        # will select TestMyClass.test_something 
        # but not TestMyClass.test_method_simple 

我想什麼了是這樣的表達:

pytest -v test_file.py -k 「TestTest and not test_bad」 

而且我得到的錯誤是:

ERROR: file not found: and 

其他變化我都試過,在同一失敗告終:

pytest -v -k 「TestTest and not test_bad」 
pytest -v -k 「TestTest and not test_bad」 test_file.py 

最後我pytest的版本是:3.0.3

+0

是'test_file.py'與您正在運行py.test命令的位置相同的位置嗎?基本上這個錯誤意味着找不到文件'test_file.py'。嘗試給出完整的路徑。 – Sanju

回答

0

有一些怪異的印刷報價,而不是用於防止終端說法分裂,這意味着你的pytest實際上得到四個參數的" ASCII報價: 「TestTest,and,nottest_bad」

您的示例在使用"代替時適用於我。

+0

好眼睛,我得到了通過電子郵件發送給我的原始命令,我想這些奇怪的報價類型。我應該意識到這一點,因爲這不是我第一次這樣做...... –