代码之家  ›  专栏  ›  技术社区  ›  Michael Durrant

由于未定义pytest,跳过编写程序测试

  •  1
  • Michael Durrant  · 技术社区  · 6 月前

    我可以运行我的python剧作家测试了

    不过我想跳过一个

    我补充道 @pytest.mark.skip 但我弄错了 'pytest' is not defined

    进口再 从playwright.sync_api导入页面,期望

    def test_has_title(page: Page):
        page.goto("https://bbc.com")
    
        # Expect a title "to contain" a substring.
        expect(page).to_have_title(re.compile("BBC Home"))
    
    @pytest.mark.skip('skip')
    def test_get_started_link(page: Page):
        page.goto("https://bbc.com")
    
        # Click the get started link.
        page.get_by_role("link", name="Home").click()
    
        # Expects page to have a heading with the name of Installation.
        expect(page.get_by_role("heading", name="BBC")).to_be_visible()
    
    ==================================== ERRORS =====================================
    _________________________ ERROR collecting test_bbc.py __________________________
    test_bbc.py:10: in <module>
        @pytest.mark.skip('skip')
    E   NameError: name 'pytest' is not defined
    ============================ short test summary info ============================
    ERROR test_bbc.py - NameError: name 'pytest' is not defined
    !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!
    =============================== 1 error in 0.03s ================================
    
    1 回复  |  直到 6 月前
        1
  •  1
  •   J_H    6 月前

    您要添加:

    import pytest