pytest-cov doesn't work when sync_playwright is active
See original GitHub issueHi. Love the project. Found an oddity, thought I should report it.
pytest-cov
coverage doesn’t appear to be collected when sync_playwright
is active.
I’m using the following versions: playwright 0.162.1 pytest 6.1.2 pytest-cov 2.10.1 Recreated on python 3.9, 3.8, 3.7.
Here’s the minimal reproduction:
import playwright
import pytest
def test_playwright_breaks_coverage():
print('coverage works here')
with playwright.sync_playwright() as p:
print('but coverage doesnt work here')
browser = p.chromium.launch(headless=True)
try:
page = browser.newPage()
page.setViewportSize(1024, 768)
page.goto('https://google.com')
finally:
browser.close()
print('or here')
print('coverage works here')
Run with python -m pytest test_playwright_breaks_coverage.py --cov-report=html --cov=test_playwright_breaks_coverage
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Pytest coverage not working correctly when using Playwright
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 ...
Read more >pytest and coverage combination does not work - Stack Overflow
The --cov parameter takes an argument saying which paths to cover. In your example, --cov would consume test.py , but then there were...
Read more >Release 4.0.0 pytest-cov contributors
This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras: • Subprocess support: you can fork ...
Read more >Code coverage using pytest and codecov.io
I got my asgi-csrf Python package up to 100% code coverage. Here's the pull request. I started by installing and using the pytest-cov...
Read more >Python Friday #53: Code Coverage for Pytest
This code was made so bad on purpose and what works here will work with your code base as well. First steps. Let...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Magnificent. It worked like a charm.
Add the following settings to
.coveragerc
in the project directory:Thank you for your help.