跳过剧作家测试会导致 pytest 未定义

问题描述 投票:0回答:1

我可以运行我的 python playwright 测试了

但是我想跳过一个

我添加了

@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 ================================
python pytest playwright
1个回答
0
投票

您要添加:

import pytest
© www.soinside.com 2019 - 2024. All rights reserved.