- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 457
 
Description
Not sure if this is a bug in coverage itself, but as pinning coverage to 6.4 fixed it for us, i'll ask here first.
When i run pytest with coverage 6.4.1 or 6.4.2, putting a breakpoint in the code (or in the test code) will start a shell one level deeper than where the breakpoint is. To return to the breakpoint location, i have to type up.
Test code:
import pytest
pytestmark = pytest.mark.django_db
def test_view_homepage(django_app):
    response = django_app.get("/")
    breakpoint()
    assert response.status_code == 200(With the shell env PYTHONBREAKPOINT=ipdb.set_trace)
Running the test with the breakpoint:
$ pytest -k test_view_homepage
Test session starts (platform: linux, Python 3.9.13, pytest 7.1.2, pytest-sugar 0.9.5)
cachedir: .pytest_cache
django: settings: my_project.settings.test (from ini)
rootdir: /home/kees/Projects/myproject, configfile: setup.cfg, testpaths: my_project, site_settings
plugins: mock-3.8.2, freezegun-0.4.2, sugar-0.9.5, django-4.5.2, black-0.3.12, Faker-13.15.0, flake8-1.1.1, isort-3.0.0, factoryboy-2.5.0, django-constance-2.9.0, xdist-2.5.0, forked-1.4.0, django-webtest-1.9.10, cov-3.0.0
collecting ... Creating test database for alias 'default'...
--Call--
> /home/kees/Projects/myproject/env/lib/python3.9/site-packages/django_webtest/response.py(17)status_code()
     16 
---> 17     @property
     18     def status_code(self):
ipdb> up
> /home/kees/Projects/myproject/my_project/tests/test_view_homepage.py(9)test_view_homepage()
      8     breakpoint()
----> 9     assert response.status_code == 200
     10 
ipdb> 
I'd expect to get a shell at the breakpoint location, but what happens is i have to go up one frame to get there. Pinning coverage to 6.4 fixes this. Other used packages are in the attached requirements.txt file.
This may be related to #1402 which also happens in the same version of coverage, and is also about breakpoints.