Skip to main content

plugin for rich text descriptions

Project description

pytest-describe-it

PyPI version PyPI - Python Version Build Status

Example

Some simple test:

import pytest


def add(x: int, y: int) -> int:
    return x + y


@pytest.mark.describe('add')
class TestAdd:

    @pytest.mark.parametrize(['x', 'y', 'expected'], [
        (1, 2, 3),
        (3, 4, 7),
        (5, 6, 10),
    ])
    @pytest.mark.it('returns {expected} for add({x}, {y})')
    def test_add(self, x, y, expected):
        assert add(x, y) == expected

Pytest output:

collected 3 items

test_add.py ..F                                                                 [100%]

====================================== FAILURES =======================================
________________ TestAdd.test_add[[ add  returns 10 for add(5, 6) ]] _________________

self = <test_add.TestAdd object at 0x10b740b70>, x = 5, y = 6, expected = 10

    @pytest.mark.parametrize(['x', 'y', 'expected'], [
        (1, 2, 3),
        (3, 4, 7),
        (5, 6, 10),
    ])
    @pytest.mark.it('returns {expected} for add({x}, {y})')
    def test_add(self, x, y, expected):
>       assert add(x, y) == expected
E       assert 11 == 10
E        +  where 11 = add(5, 6)

test_add.py:18: AssertionError
========================= 1 failed, 2 passed in 0.05 seconds ==========================

With pytest-sugar:

collecting ...
 test_add.py ✓✓                                                          67% ██████▋

―――――――――――――――― TestAdd.test_add[[ add  returns 10 for add(5, 6) ]] ―――――――――――――――――

self = <test_add.TestAdd object at 0x10e4e3550>, x = 5, y = 6, expected = 10

    @pytest.mark.parametrize(['x', 'y', 'expected'], [
        (1, 2, 3),
        (3, 4, 7),
        (5, 6, 10),
    ])
    @pytest.mark.it('returns {expected} for add({x}, {y})')
    def test_add(self, x, y, expected):
>       assert add(x, y) == expected
E       assert 11 == 10
E        +  where 11 = add(5, 6)

test_add.py:18: AssertionError

 test_add.py                                                           100% ██████████

Results (0.10s):
       2 passed
       1 failed
         - test_add.py:11 TestAdd.test_add[[ add  returns 10 for add(5, 6) ]]

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-describe-it, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_describe_it-0.1.0-py2.py3-none-any.whl (4.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pytest-describe-it-0.1.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page