py.test

    10熱度

    1回答

    當我在本地運行測試時它的工作正常,但是在創建docker並在容器內運行後,我得到了錯誤。 /usr/local/lib/python3.5/site-packages/_pytest/config.py:325: in _getconftestmodules return self._path2confmods[path] E KeyError: local('/apis/db/tes

    1熱度

    2回答

    我想用pytest編寫一個測試,當一個函數在不同的運行中有不同的結果時,它會失敗。一個簡單的例子是hash("abc") 在終端: $> python -c 'print(hash("abc"))' 7757446167780988571 $> python -c 'print(hash("abc"))' -1754122997235049390 然而在一次運行,我們當然有: >>> h

    2熱度

    1回答

    由於某些原因,我不能讓mock.patch在任何情況下使用Pytest工作。它根本不做補丁。我是不是正確使用它,或者是我的配置搞砸了? base.py def foo(): return 'foo' def get_foo(): return foo() test_base.py import pytest import mock from pytest_mock

    2熱度

    1回答

    通過一些關於pytest的教程。我瞭解到, python -m pytest 這個命令執行的前綴test_中的所有文件開始以及功能,文件位於同一目錄中。但我的問題是,如果文件是test_app_id.py,test_sum.py,test_average.py,test_multiply.py首先執行該文件。

    0熱度

    1回答

    雖然試圖使單元測試(使用py.test)更通用,我正在編程生成測試。 - 我有一個函數可以輸出參數和測試結束時的不變量。 現在爲了保持整潔,我也希望通過測試ID。通過pytest的官方(?)文檔,我注意到: import pytest from datetime import datetime, timedelta # ... @pytest.mark.parametrize("a,b

    0熱度

    2回答

    我想在python中使用pytest和selen編寫web應用程序的測試代碼。 我的代碼如下所示: from selenium import webdriver import pytest import time def test_OpenBE(browser): browser.get('urlremoved.com') def test_navigateToSubmit(

    1熱度

    1回答

    例如,我有一些代碼,試圖訪問列表: def some_code(): script_dir = os.path.dirname(sys.argv[0]) 我需要模擬sys.argv[0]。所以我在我的測試中加入@patch.object: import os import sys THIS_DIR = os.path.dirname(os.path.abspath(__file

    1熱度

    1回答

    我有以下腳本: conftest.py: import pytest @pytest.fixture(scope="session") def setup_env(request): # run some setup return("result") test.py: import pytest @pytest.mark.usefixtures("setup_env"

    2熱度

    1回答

    我正在使用pytest-html插件來生成我的測試用例的報告。如果腳本失敗,我想添加一個訂單項。所以這裏是我的代碼--- import pytest @pytest.mark.hookwrapper def pytest_runtest_makereport(item, call): pytest_html = item.config.pluginmanager.getplugin

    0熱度

    1回答

    我使用的自動化框架運行在多個Web應用程序上,其中一些鍵盤快捷鍵如AltGr + "2"或shift + "S"。 我們面臨的問題是,這樣做簡單的東西: element.send_keys('T')或element.send_keys('!')的shift + "t"或shift + "1"快捷方式被觸發。相反,當運行element.send_keys('t')之類的東西時,它會按照預期輸入t。