py.test

    0熱度

    2回答

    我習慣用命令狀 pytest.main('-s path_to_file --my_fixtures_arg1 arg_value') 目前,這樣的電話被認爲是過時運行測試,你需要通過參數列表來調用這個命令。但我無法以任何方式傳遞必要的參數。誰知道解決方案?

    0熱度

    1回答

    我有一個參數化測試,它需要str和dict作爲參數,所以如果我允許pytest生成id,名稱看起來很奇怪。 所以我雖然使用函數生成自定義ID,但它看起來沒有按預期工作。 def id_func(param): if isinstance(param, str): return param @pytest.mark.parametrize(argnames=('date'

    0熱度

    1回答

    我想寫我的自定義錯誤頁面視圖測試運行使用`DEBUG = TRUE`測試: - 文件可以發現here 而且對於我已經包含了這些網址,編寫測試用例作爲建議here: - if settings.DEBUG: urlpatterns += [ url(r'^404/$', page_not_found_view), url(r'^500/$', my_custom_e

    0熱度

    1回答

    我創建圍繞SQLAlchemy的數據庫引擎/連接/會話中的「經理」對象: Base = declarative_base() class Manager(object): def __init__(self, connection: str = 'sqlite://'): self.engine = create_engine(connection, echo=True)

    3熱度

    1回答

    我是初學者,在python中使用pytest並試圖爲以下方法編寫測試用例,該方法在傳遞正確標識時獲取用戶地址,否則會自定義錯誤BadId。 def get_user_info(id: str, host='127.0.0.1', port=3000) -> str: uri = 'http://{}:{}/users/{}'.format(host,port,id) resul

    0熱度

    2回答

    我有一個需要在我的測試套件中使用燈具的功能。這只是一個幫助生成完整URL的小幫助函數。 def gen_url(endpoint): return "{}/{}".format(api_url, endpoint) 我在conftest.py夾具返回的網址: @pytest.fixture(params=["http://www.example.com"]) def api_url

    1熱度

    1回答

    在unittest樣式中,我可以通過調用assertTemplateUsed來測試某個頁面是否使用特定模板。例如,當Django通過模板插入值時,這非常有用,這樣我就不能測試字符串相等。 我該如何在pytest中編寫相應的語句? 我一直在尋找pytest-django,但不知道該怎麼做。

    0熱度

    1回答

    我使用pytest與一些複雜的依賴注入裝置。我有固定裝置在長鏈中使用其他裝置。我希望能夠在鏈條中間修改一些固定裝置以進行特定的測試。 鑑於這些(簡體)燈具: @pytest.fixture def cache(): return Cache() # Use cache fixture in a new fixture. @pytest.fixture def resource(

    0熱度

    1回答

    中定義了Cases.py文件,定義套件: import unittest import pytest from adminzone_tests.Clients import TestClients def collect_suite(): suite = unittest.TestSuite() suite.addTest(TestClients) retu

    6熱度

    1回答

    我想爲以下異步,等待方法寫pytest,但我無處可去。 class UserDb(object): async def add_user_info(self,userInfo): return await self.post_route(route='users',json=userInfo) async def post_route(self,route=Non