Azure / pytest-azurepipelines

Plugin for pytest that makes it simple to work with Azure Pipelines
MIT License
113 stars 35 forks source link

Cleaner test names when using docstrings #11

Closed JasonIRL closed 5 years ago

JasonIRL commented 5 years ago

First off, thank you for writing this plugin. 👍

The output is a bit cluttered when the test functions have multi-line docstrings. For example, take this test suite, which has a test for each of the more "conventional" docstring styles (PEP 257, Google, NumPy):

import pytest

@pytest.mark.parametrize("x", [1, "string"])
def test_google_docstring(x):
    """Test Google Docstrings

    This test is to test how google docstrings are displayed in an Azure Pipeline.

    Args:
        x (int): An Integer.

    """
    assert type(x) is int

@pytest.mark.parametrize("x", [1, "string"])
def test_numpy_docstring(x):
    """Test NumPy Docstrings

    this test is to test how numpy docstrings are displayed in an Azure Pipeline.

    Parameters
    ----------
    x: int
        An Integer.

    """
    assert type(x) is int

@pytest.mark.parametrize("x", [1, "string"])
def test_multi_line_docstring(x):
    """Test multi-line Docstrings

    This test is to test how PEP 257 multi-line docstrings are displayed in an Azure
    Pipeline.

    Keyword arguments:
    x -- An Integer

    """
    assert type(x) is int

Each test above will pass and fail, based on the parameter passed to the test function, so that I can see the results in an Azure Pipeline build.

It gets a little messy in the pipeline test results, because it pulls the entire docstring in as the test name, but also ignores the parameters:

Test Results

I have an idea to fix it, and will submit a pull request with those changes after I test it some more.

tonybaloney commented 5 years ago

Agreed. Thank you for submitting this issue

tonybaloney commented 5 years ago

Merged, thanks for submitting the issue