Skip to content

VSCode 'Run tests' for Python pytest reports warning for junit_family #9709

Closed
@pi-bjl

Description

@pi-bjl

Environment data

  • VS Code version:
    Version: 1.41.1 (user setup)
    Commit: 26076a4de974ead31f97692a0d32f90d735645c0
    Date: 2019-12-18T14:58:56.166Z
    Electron: 6.1.5
    Chrome: 76.0.3809.146
    Node.js: 12.4.0
    V8: 7.6.303.31-electron.0
    OS: Windows_NT x64 10.0.18363

  • Extension version (available under the Extensions sidebar):
    Name: Python
    Id: ms-python.python
    Description: Linting, Debugging (multi-threaded, remote), Intellisense, Jupyter Notebooks, code formatting, refactoring, unit tests, snippets, and more.
    Version: 2020.1.58038
    Publisher: Microsoft
    VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

  • OS and version: Windows_NT x64 10.0.18363

  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.4

  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv

  • Relevant/affected Python packages and their versions: pytest 5.3.2

  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): checked

Expected behaviour

As per pytest-dev/pytest#6179 , if you call pytest withOUT --junitxml, there should be no warning related to junit_family.

Actual behaviour

If I call pytest from Powershell commandline, output is as expected. However if I use 'Run All Tests' in VSCode, I get the following warning:

============================== warnings summary ===============================
pythonpracticevenv\lib\site-packages\_pytest\junitxml.py:436
  c:\Users\bjl\Workspace\pythonpractice\pythonpracticevenv\lib\site-packages\_pytest\junitxml.py:436: PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
  Add 'junit_family=xunit1' to your pytest.ini file to keep the current format in future versions of pytest and silence this warning.
    _issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
- generated xml file: C:\Users\bjl\AppData\Local\Temp\tmp-18456cj6q2xypP4yi.xml -

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. My file is just test_helloworld.py with following contents:
def helloworld(name='World'):
    return f"Hello, {name}!"

####################################################

def test_helloworld_default():
    assert helloworld() == "Hello, World"

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

> c:\Users\bjl\Workspace\pythonpractice\pythonpracticevenv\Scripts\python.exe -m pytest --rootdir c:\Users\bjl\Workspace\pythonpractice --junitxml=C:\Users\bjl\AppData\Local\Temp\tmp-18456cj6q2xypP4yi.xml tests
cwd: c:\Users\bjl\Workspace\pythonpractice

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

  • This instruction doesn't make sense to me, nonetheless the source of the error is pretty obvious. VSCode is adding the --junitxml flag for its own purposes, it should also supply a value for junit_family in some unobtrusive way.

As a workaround, I will add junit_family=legacy in my own pytest.ini to silence the warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions