Skip to main content

A pspec format reporter for pytest

https://i.imgur.com/cCMJXHe.png

Install

pip install pytest_aspec

Usage

Add the parameter –pspec when running pytest. Ex:

pytest --pspec your-tests/

Tip: If you don’t want to type --pspec every time you run pytest, add it to addopts in your ini file. Ex:

# content of pytest.ini
# (or tox.ini or setup.cfg)
[pytest]
addopts = --pspec

Demo Code

Add the doc strings Ex:

import unittest

class TestWayTwo(unittest.TestCase):
    "Pspec Python TDD"

    def test_should_add(self):
        "it adds two integers and returns integer"
        self.assertEqual(2+2, 4)

    def test_should_find_difference_between_integers(self):
        self.assertEqual(4-2, 2)

running pytest --pspec outputs

demo
 🌸 it adds two integers and returns integer
 🌸 should find difference between integers

Configuration file options

pspec_passed

Specifies pspec passed character. Ex:

# content of pytest.ini
# (or tox.ini or setup.cfg)
[pytest]
pspec_passed=\N{heavy check mark}\N{vs16}
$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 ✔️ prints a BDD style output to your tests
 ✔️ lets you focus on the behavior

pspec_failed

Specifies pspec failed character. Ex:

# content of pytest.ini
# (or tox.ini or setup.cfg)
[pytest]
pspec_failed=\N{skull and crossbones}\N{vs16}
$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 🌸️ this failed??!!

pspec_skipped

Specifies pspec skipped character. Ex:

# content of pytest.ini
# (or tox.ini or setup.cfg)
[pytest]
pspec_skipped=\N{snowman without snow}\N{vs16}
$ pytest test_demo.py
============================= test session starts ==============================
platform darwin -- Python 3.5.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /private/tmp/demo, inifile: pytest.ini
plugins: pspec-dev
collected 2 items

test_demo.py
Pytest pspec
 ☃️️ skipping this test for now

Release files for pytest-aspec 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-aspec 1.3
File Size Uploaded
pytest_aspec-1.3.tar.gz 4.8 kB Details

Release files / pytest_aspec-1.3.tar.gz

Download URL pytest_aspec-1.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
50fd461551f2a35448e49af6fdfeb2e7b1eb45d361bc0250fed2cfd20ccedd9b
BLAKE2b-256 checksum
How to use checksums
4b48ff6a4156bd8c33c3f2fe6545c3efd4c3e9758555f5b3614aa344512ee84a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.3 This release

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.11

1 release file

0.10

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page