py.test

    1熱度

    1回答

    我有一個庫,它支持3.5和3.6並廣泛使用asyncio。我想要有可以在3.5和3.6下工作的異步夾具,但這非常困難。到目前爲止我發現的最好的方法是編寫我自己的fixture裝飾器來解決3.5和3.6中的差異。該庫基本上從外部源獲取數據驅動的協同程序鏈。我想測試一下生成的協程鏈。 我的夾具和測試這個樣子的(和工作在3.5): @pytest.mark.asyncio test_my_corout

    0熱度

    1回答

    我已經知道如何在pytest中傳遞命令行參數。 我想打印或在我的setup_class()或setup_module()中對作爲命令行參數傳遞的變量進行一些基本驗證。 我可以在測試方法中訪問這些變量,但不能在setup_class或setup_module中訪問這些變量。這甚至有可能嗎? 我想要做這樣的事情... conftest.py def pytest_addoption(parser):

    0熱度

    1回答

    我對編程有些新鮮感,到目前爲止,我的大部分程序都是單一的目錄事務,但現在我想嘗試更大的東西,而且我無法使導入工作。我使用pytest來創建我的單元測試,並且在我的test_foo.py文件中的單元測試定義之後,我一直使用獨立測試腳本。這工作正常,直到我添加__init__.py文件。如果使用import card as crd test_card.py進口卡 文件安排1 StackOverflow

    4熱度

    1回答

    我對三個模型類使用SQLalchemy關聯對象模式(http://docs.sqlalchemy.org/en/rel_1_1/orm/basic_relationships.html#association-object)。 基本關係在左側一個用戶可以屬於多個組織。我在關聯對象類中存儲了額外的用戶 - 組織相關數據。然後,關聯對象類將多對一映射到組織。 從SQLAlchemy的角度來看,這種關係

    1熱度

    1回答

    我正在使用Python 3.4.6。 這裏是工廠: def create_parser(): """ Create argument parser """ # Input configuration parameters _parser = argparse.ArgumentParser(description='Segments Engine') #

    1熱度

    3回答

    我有一個Django應用程序,工作正常。當我使用pytest運行測試時,它只能與實用程序類一起工作(所以不是與Django相關的)。 例如,軟件包A從該軟件包或其他軟件調用實用程序類的測試工作正常。 但是,只要我導入一個django類,我就會面臨錯誤。 例如1: 導入我的模型(測試),以開始測試類: from app.common.models import Country - >導入錯誤:沒

    0熱度

    1回答

    我有一個問題,我在一個文件中有2個測試,並且只想用一次登錄就運行它們。 from selenium.webdriver.common.by import By from methods.is_present import is_element_present, is_element_present_n from methods.users import add_new_user, delete

    0熱度

    1回答

    使用testinfra(Pytest插件)進行測試。我想用私鑰來測試Jenkins的遠程主機。 [[email protected] tests]# testinfra --ssh-config=/path/to/private/key --sudo [email protected] test.py 其中 cat /path/to/private/key -----BEGIN RSA PRIV

    1熱度

    1回答

    失敗比方說,我有一個測試,如下圖所示: import pytest import copy @pytest.fixture(scope='session') def session_tool(request): tool = request.config.tool # Build is the critical part and may fail, raising an

    1熱度

    1回答

    我在使用pytest運行單元測試用例時遇到此錯誤。 它在我的項目中工作正常,但運行測試用例時會引發錯誤。 我的代碼如下: def saveEvents(request, request_data): transaction.set_autocommit(autocommit=False) try: # here is my code except Exce