Skip to content

Django Testing Error #24657

Description

Type: Bug

I am trying to use the Django testing feature implemented in August, but I am encountering difficulties. I am using a Conda environment inside a dev container that utilizes this image: continuumio/miniconda3:latest. However, when I try to run the tests, I get the following errors:

2024-12-24 17:49:50.742 [info] Discover tests for workspace name: EDDAI-EliteDangerousApiInterface - uri: /workspaces/EDDAI-EliteDangerousApiInterface
2024-12-24 17:49:50.742 [info] Running discovery for unittest using the new test adapter.
2024-12-24 17:49:50.756 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/printEnvVariables.py
2024-12-24 17:49:50.756 [info] shell: bash
2024-12-24 17:49:51.896 [info] Discovering unittest tests for workspace /workspaces/EDDAI-EliteDangerousApiInterface with arguments: /root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/unittestadapter/discovery.py,--udiscovery,-p,test.py

2024-12-24 17:49:51.896 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/python_files/unittestadapter/discovery.py --udiscovery -p test.py
2024-12-24 17:49:51.896 [info] cwd: .
2024-12-24 17:49:52.914 [info] >>>PYTHON-EXEC-OUTPUT

2024-12-24 17:49:52.947 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $/workspaces/EDDAI-EliteDangerousApiInterface/eddai_EliteDangerousApiInterface/manage.py

2024-12-24 17:49:52.951 [info] Running Django tests with command: ['/opt/conda/bin/python', '/workspaces/EDDAI-EliteDangerousApiInterface/eddai_EliteDangerousApiInterface/manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '-p', 'test.py']

2024-12-24 17:49:57.044 [error] Test Discovery named pipe /tmp/user/0/python-test-discovery-a8be1522eb245c648034 error: TypeError: Cannot read properties of null (reading 'path')
at e (/root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:963511)
at t.PythonResultResolver._resolveDiscovery (/root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:942532)
at t.PythonResultResolver.resolveDiscovery (/root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:941616)
at /root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:1011606
at b.callback (/root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:962221)
at Object.thunk (/root/.vscode-server/extensions/ms-python.python-2024.22.1-linux-x64/out/client/extension.js:2:2057316)
2024-12-24 17:49:57.186 [error]

2024-12-24 17:49:57.186 [info] Found 0 test(s).

<<<PYTHON-EXEC-OUTPUT

I don't think this is an issue caused by the dev container. Below, I am also providing the environment.yml file from Conda with my dependencies to help you understand the problem:

`channels:

  • conda-forge
  • defaults
    dependencies:
  • geos=3.12.2
  • gdal=3.9.1
  • proj=9.4.1
  • python=3.11.9
  • psycopg2=2.9.9
  • libarchive=3.7.7
  • pip:
    • celery==5.4.0
    • django==5.1.0
    • django-filter==24.2
    • djangorestframework==3.15.1
    • djangorestframework-gis==1.1
    • gevent==24.2.1
    • redis==5.0.4
    • pyzmq==26.0.3
    • psycopg==3.2.1

Lastly, I am including the Docker file that generates my dev container for completeness.

FROM continuumio/miniconda3:latest

COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi
&& rm -rf /tmp/conda-tmp

Extension version: 2024.22.1
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 5.15.133.1-microsoft-standard-WSL2

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


languageServer: "Pylance"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

Installed Extensions
Extension Name Extension Id Version
Bracket Pair Colorization Toggler dzhavat.bracket-pair-toggler 0.0.3
Git Graph mhutchie.git-graph 1.30.0
GitHub Copilot GitHub.copilot 1.254.0
GitHub Copilot Chat GitHub.copilot-chat 0.23.2
GitHub Pull Requests GitHub.vscode-pull-request-github 0.102.0
Italian Language Pack for Visual Studio Code MS-CEINTL.vscode-language-pack-it 1.96.2024121109
JavaScript Debugger ms-vscode.js-debug 1.96.0
Prettier - Code formatter esbenp.prettier-vscode 11.0.0
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.1
Python Debugger ms-python.debugpy 2024.14.0
snappify snappify.snappify 1.0.2
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i7-1260P (16 x 2496)
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.70GB (10.79GB free)
Process Argv --folder-uri file:///c%3A/Users/fabio/Documents/GitHub/EDDAI-EliteDangerousApiInterface --crash-reporter-id 7a609e3a-ffca-4e82-8085-4b26c3179ade
Screen Reader no
VM 0%
Item Value
Remote Contenitore di sviluppo: eddia-devcontainer @ desktop-linux
OS Linux x64 5.15.133.1-microsoft-standard-WSL2
CPUs 12th Gen Intel(R) Core(TM) i7-1260P (16 x 0)
Memory (System) 15.47GB (12.25GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
newcmakeconfigv2:31071590
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

Activity

  1. fabietto01 commented on Dec 24, 2024

    @fabietto01
    Author

    I also tried from my host system, a Windows machine, without using the dev container, and I get the same error only on Windows.

    2024-12-24 19:08:58.483 [info] Discover tests for workspace name: EDDAI-EliteDangerousApiInterface - uri: c:\Users\fabio\Documents\GitHub\EDDAI-EliteDangerousApiInterface
    2024-12-24 19:08:58.483 [info] Running discovery for unittest using the new test adapter.
    2024-12-24 19:08:58.488 [info] > ~\miniconda3\Scripts\conda.exe run -p ..conda --no-capture-output python ~.vscode\extensions\ms-python.python-2024.22.1-win32-x64\python_files\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.22.1-win32-x64/python_files/printEnvVariables.py
    2024-12-24 19:08:58.488 [info] shell: commandPrompt
    2024-12-24 19:09:00.437 [info] Discovering unittest tests for workspace c:\Users\fabio\Documents\GitHub\EDDAI-EliteDangerousApiInterface with arguments: c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\python_files\unittestadapter\discovery.py,--udiscovery,-p,test.py

    2024-12-24 19:09:00.437 [info] > ~\miniconda3\Scripts\conda.exe run -p ..conda --no-capture-output python ~.vscode\extensions\ms-python.python-2024.22.1-win32-x64\python_files\get_output_via_markers.py ~.vscode\extensions\ms-python.python-2024.22.1-win32-x64\python_files\unittestadapter\discovery.py --udiscovery -p test.py
    2024-12-24 19:09:00.437 [info] cwd: .
    2024-12-24 19:09:02.290 [info] >>>PYTHON-EXEC-OUTPUT

    2024-12-24 19:09:02.469 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $C:\Users\fabio\Documents\GitHub\EDDAI-EliteDangerousApiInterface\eddai_EliteDangerousApiInterface\manage.py

    2024-12-24 19:09:02.469 [info] Running Django tests with command: ['c:\Users\fabio\Documents\GitHub\EDDAI-EliteDangerousApiInterface\.conda\python.exe', 'C:\Users\fabio\Documents\GitHub\EDDAI-EliteDangerousApiInterface\eddai_EliteDangerousApiInterface\manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '-p', 'test.py']

    2024-12-24 19:09:04.638 [error] Test Discovery named pipe \.\pipe\python-test-discovery-c8d35517c3a59356ecbe error: TypeError: Cannot read properties of null (reading 'path')
    at e (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:963511)
    at t.PythonResultResolver._resolveDiscovery (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:942532)
    at t.PythonResultResolver.resolveDiscovery (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:941616)
    at c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:1011606
    at _._callback (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:962221)
    at b.callback (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:204363)
    at Object.thunk (c:\Users\fabio.vscode\extensions\ms-python.python-2024.22.1-win32-x64\out\client\extension.js:2:2057316)
    2024-12-24 19:09:04.852 [error]

    2024-12-24 19:09:04.853 [info] Found 0 test(s).

    <<<PYTHON-EXEC-OUTPUT

    The Conda environment was created from VSCode by clicking on "Create Virtual Environment" and selecting Conda.

  2. eleanorjboyd commented on Jan 6, 2025

    @eleanorjboyd
    Member

    Hi! This is very interesting, here are some of my thoughts. First, it seems you get it on both machines so it is likely not a permissions error but we see similar errors for permissions so that could be a reason. What would help is if you could test it from the command line to see if you can get a result there. First you will need to add the parent folder of the script we are using to your python path. It should be somewhere here ~/.vscode-insiders/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/unittestadapter (with different versions and maybe .vscode not .vscode-insiders).. Now run the command your logs included here Running Django tests with command: ['/opt/conda/bin/python', '/workspaces/EDDAI-EliteDangerousApiInterface/eddai_EliteDangerousApiInterface/manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '-p', 'test.py'] as a string with spaces. Let me know how that goes. Thanks!

  3. changed the title [-]Djnago Testing Error[/-] [+]Django Testing Error[/+] on Jan 6, 2025
  4. fabietto01 commented on Jan 7, 2025

    @fabietto01
    Author

    Hi,
    I’ve run the test you asked for. Below is the terminal output:

    terminale.txt

    As you can see, at the beginning, I looked for the directory you mentioned. Then, I added the main folder of the script, went back to the project directory, and executed the command. Let me know if I followed the steps correctly and if there’s anything else I can do to help you resolve the issue.

    Thank you for your support.

  5. lukasz-karolewski commented on Apr 4, 2025

    @lukasz-karolewski

    i have the same problem:
    PYTHONPATH seems to be set correctly, i've added print() inside manage.py

    2025-04-04 21:23:58.685 [info] Discover tests for workspace name: test_project - uri: /workspace/test_project
    2025-04-04 21:23:58.690 [info] Discovering unittest tests for workspace /workspace/test_project with arguments: /root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter/discovery.py,--udiscovery,-v,2
    
    2025-04-04 21:23:58.743 [info] > /usr/local/python/current/bin/python ~/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter/discovery.py --udiscovery -v 2
    2025-04-04 21:23:58.743 [info] cwd: .
    2025-04-04 21:23:58.785 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $./django/manage.py
    
    2025-04-04 21:23:58.785 [info] Running Django tests with command: ['/usr/local/python/current/bin/python', './django/manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '-v', '2']
    
    2025-04-04 21:23:59.394 [error] Test Discovery named pipe /tmp/python-test-discovery-683bf85fbd22591ff3c2 error: TypeError: Cannot read properties of null (reading 'path')
        at e (/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:931664)
        at t.PythonResultResolver._resolveDiscovery (/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:916288)
        at t.PythonResultResolver.resolveDiscovery (/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:915372)
        at /root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:967569
        at b.callback (/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:931208)
        at Object.thunk (/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/out/client/extension.js:2:1985138)
    2025-04-04 21:23:59.507 [error] 
    2025-04-04 21:23:59.508 [info] PYTHONPATH: /root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter
    2025-04-04 21:23:59.509 [info] Using settings: test_project.settings.test
    Found 0 test(s).
    

    i've tried running from terminal directly:

    test_project git:(dev) ✗ PYTHONPATH=/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter /usr/local/python/current/bin/python django/manage.py test --testrunner=django_test_runner.CustomDiscoveryTestRunner -v 2
    PYTHONPATH: /root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter
    Using settings: test_project.settings.test
    UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. Please confirm this environment variable is not being changed or removed as it is required for successful test discovery and execution.TEST_RUN_PIPE = None
    
    Traceback (most recent call last):
      File "/workspace/test_project/django/manage.py", line 16, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
        utility.execute()
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
        super().run_from_argv(argv)
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
        self.execute(*args, **cmd_options)
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
        output = self.handle(*args, **options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/python/3.12.9/lib/python3.12/site-packages/django/core/management/commands/test.py", line 63, in handle
        failures = test_runner.run_tests(test_labels)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/root/.vscode-server/extensions/ms-python.python-2025.4.0-linux-x64/python_files/unittestadapter/django_test_runner.py", line 46, in run_tests
        raise VSCodeUnittestError(error_msg)
    pvsc_utils.VSCodeUnittestError: UNITTEST ERROR: TEST_RUN_PIPE is not set at the time of unittest trying to send data. Please confirm this environment variable is not being changed or removed as it is required for successful test discovery and execution.TEST_RUN_PIPE = None```
    
    
    
    settings: 
    
    ```"python.experiments.optInto": ["pythonTestAdapter"],
    "python.testing.promptToConfigure": false,
    "python.testing.unittestArgs": ["-v", "2"],
    "python.testing.pytestEnabled": false,
    "python.testing.unittestEnabled": true,
    "python.envFile": "${workspaceFolder}/django/.env",```
    
  6. eleanorjboyd commented on Sep 23, 2026

    @eleanorjboyd
    Member

    🤖 Thanks for the report and the additional reproduction. Current main now avoids the Cannot read properties of null (reading 'path') exception when Django discovery returns a null test tree, but that change does not establish whether your tests are now discovered. Could you confirm this with the current Python extension or pre-release and provide a minimal Django project plus the latest Python output-channel log if it still finds zero tests? Issues marked info-needed automatically close after 30 days without a reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bugconfirmation pendingThe issue needs to be confirmed through a maintainer reproducing the bug.info-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions