py.test

    4熱度

    2回答

    pytest_runtest_makereport()獲取兩個參數,item和call。從項目,我能找到我這個測試創建的funcarg,以及電話,我可以查找異常信息(如果有的話): def pytest_runtest_makereport (item, call): my_funcarg = item.funcargs['name'] my_funcarg.excinfo =

    13熱度

    4回答

    我試圖在我的包上運行py.test,但它試圖從項目根目錄中解析setup.py,即使我試圖排除它。 我需要從* .py文件收集測試,因爲測試類包含在模塊中。 # setup.cfg [pytest] norecursedirs = .svn _build tmp* lib/third lib *.egg bin distutils setup.py python_files = *.py

    2熱度

    2回答

    我有一個小的Python包tendo,我要讓它運行,測試並安裝了廣泛的Python版本,從2.5和3.2 結束,我需要2.5的支持,因爲我們仍然有機器上運行它並且不能升級。 當前單元測試包含在模塊內部,因此當您更改模塊並運行它們時,更容易更新它們,因爲主要將運行測試。 某些模塊不適用於所有平臺。 setup.py setup.cfg tox.ini mypackage/foo.py myp

    1熱度

    2回答

    如何在funcargs函數中放入pdb?我怎樣才能看到funcargs函數中的打印語句的輸出? 我原來的問題包括以下內容,但事實證明,我只是在梳理錯誤的funcarg。嘆。 我想: print "hi from inside funcargs" 使用和不使用-s調用。 我嘗試: import pytest pytest.set_trace() 和: import pdb pdb.set

    5熱度

    1回答

    我正在使用pytest來測試嵌入式系統的python模型。要測試的功能因平臺而異。 (我在此上下文中使用「平臺」來表示嵌入式系統類型,而不是操作系統類型)。 組織我的測試最直接的方法是將它們分配到基於平臺類型的目錄。 /platform1 /platform2 /etc. pytest/PLATFORM1 這迅速成爲難以支持儘可能多的功能,跨平臺重疊。之後我將測試移到了一個目錄中,每個功能

    2熱度

    1回答

    我正在使用py.test編寫一些測試,並在我的測試中使用了funcargs。這些funcargs有自己的設置和拆解的conftest.py定義是這樣的: conftest.py: def pytest_funcarg__resource_name(request): def setup(): # do setup def teardown(): # do t

    2熱度

    1回答

    我有一個py.test測試功能標記爲xfail: @pytest.mark.xfail def test_that_fails(): assert 1 == 2 在我pytest_runtest_setup()掛鉤,我明確地跳過這個測試: def pytest_runtest_setup (item): pytest.skip ('Skipping this test')

    35熱度

    5回答

    我試圖使用setup.cfg中的norecursedirs選項來告訴py.test不要從某些目錄收集測試,但似乎它確實忽略它。 [tool:pytest] norecursedirs=lib/third 當我運行py.test我看到它是如何從內部lib/third得到測試!

    3熱度

    1回答

    使用funcargs我包括conftetst.py我自己的命令行選項 def pytest_addoption(parser): parser.addoption("--backend" , default="test_backend", help="run testx for the given backend, default: test_backend") 和 de

    5熱度

    2回答

    用下面的代碼: import pytest def test_a(): with pytest.raises(Exception): 1/0 如果我在其上運行pylint的,它將使抱怨說:「加薪」不是模塊pytest的成員: E: 3,9:test_a: Module 'pytest' has no 'raises' member 這顯然是不正確的。任何想法爲什麼p