question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest-cov doesn't work when sync_playwright is active

See original GitHub issue

Hi. 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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dcrowecommented, Nov 23, 2020

Magnificent. It worked like a charm.

Add the following settings to .coveragerc in the project directory:

[run]
concurrency = greenlet
0reactions
dcrowecommented, Nov 24, 2020

Thank you for your help.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found