Skip to content

Django tests run, but don't gather coverage #24804

Closed as duplicate of#24199
Closed as duplicate of#24199
@OutOfFocus4

Description

@OutOfFocus4

Type: Bug

Behaviour

The new test adapter properly runs Django tests, but fails to gather coverage data from those tests.

Steps to reproduce:

  1. Create a new directory /tmp/poc
  2. Create and activate a Python virtual environment:
    python -m venv /tmp/poc/.venv
    source /tmp/poc/.venv/bin/activate
  3. Install Django and coverage
    pip install django coverage
  4. Create a new Django project
    django-admin startproject poc /tmp/poc
  5. Create the file /tmp/poc/.env with the following:
    MANAGE_PY_PATH=/tmp/poc/manage.py
  6. Create a file /tmp/poc/poc/tests.py with the following:
    from django.test import TestCase
    
    class POCTest(TestCase):
        def test_poc(self):
            pass
  7. Create the file /tmp/poc/.vscode/settings.json with the following:
    {
        "python.testing.unittestEnabled": true,
        "python.testing.unittestArgs": [
        ]
    }
  8. Open the poc project in VS Code
  9. Once the tests are configured, the POCTestCase should be in the testing panel. Run it with coverage
  10. The test will succeed, but the coverage for all files except /tmp/poc/poc/__init__.py will be 0%.

Extension version: 2025.0.0
VS Code version: Code 1.97.0 (Universal) (33fc5a94a3f99ebe7087e8fe79fbe1d37a251016, 2025-02-04T22:41:26.688Z)
OS version: Darwin arm64 24.3.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

experiments
• enabled: false

Installed Extensions
Extension Name Extension Id Version
black-formatter ms- 2024.6.0
cpptools ms- 1.23.6
debugpy ms- 2025.0.0
isort ms- 2023.10.1
js-debug ms- 1.97.0
js-debug-companion ms- 1.1.3
python ms- 2025.0.0
remote-explorer ms- 0.4.3
remote-ssh ms- 0.117.0
remote-ssh-edit ms- 0.87.0
rust-analyzer rus 0.3.2299
vscode-js-profile-table ms- 1.0.10
vscode-pylance ms- 2025.2.1
vscode-yaml red 1.16.0
System Info
Item Value
CPUs Apple M1 Max (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 4, 3, 2
Memory (System) 32.00GB (2.37GB free)
Process Argv --crash-reporter-id 2c081035-5e61-4ab4-8517-c976790ae1b3
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions