-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Context:
- Playwright Version: 1.16.0
- Operating System: Linux
- Node.js version: 12.21.0
- Browser: All
Code Snippet
Take the example from the Getting Started docs and put it inside a function inside tmp.py
.
from playwright.sync_api import sync_playwright
def my_func():
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("http://playwright.dev")
print(page.title())
browser.close()
Write a pytest unit test for the function inside test_tmp.py
.
from tmp import my_func
def test_tmp():
my_func()
Describe the bug
After running coverage run -m pytest test_tmp.py
, the lines inside the with-block are not counted as covered. This really messes with the reported coverage in some of my projects because lines after a call to page.click
or page.query_selector
are not counted as covered. Is this a problem with Coverage.py or Playwright?