Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Skipping playwright test gives pytest is not defined

I can run my python playwright tests ok

However I want to skip one

I added @pytest.mark.skip but I get the error 'pytest' is not defined

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import re
from playwright.sync_api import Page, expect

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 ================================

>Solution :

You want to add:

import pytest
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading