A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it".
Project description
The pytest-pyspec plugin provides semantics to the pytest output. It transforms the pytest's output into a result similar to the RSpec.
The default pytest output is like the following:
test/test_pytest.py::TestFunction::test_use_test_name PASSED
test/test_pytest.py::TestFunction::test_use_the_prefix_test PASSED
test/test_pytest.py::TestFunction::test_use_the_prefix_it PASSED
test/test_pytest.py::TestFunction::WithDocstring::test_use_docstring PASSED
The pytest-pyspec transforms the output into the following:
A function
✓ use test name
✓ use the prefix test
✓ use the prefix it
A function
with docstring
✓ use docstring
You just need to prefix your test case classes with:
- describe / test to represent objects
- with / without to represent context
And prefix your tests with:
- it / test to represent objects
The following is a sample test that generates the previous tests` output.
class TestFunction:
def test_use_test_name(self):
assert 1 == 1
def test_use_the_prefix_test(self):
assert 1 == 1
def test_use_the_prefix_it(self):
assert 1 == 1
class WithDocstring:
def test_use_docstring(self):
assert 1 == 1
Moreover, you can use a docstring to overwrite the test description. The following tests have the same output as the previous tests:
class TestA:
""" Function """
def test_1(self):
""" use test name """
assert 1 == 1
def test_2(self):
""" use the prefix test """
assert 1 == 1
def test_3(self):
""" use the prefix it """
assert 1 == 1
class TestB:
""" with docstring """
def test_4(self):
""" use docstring """
assert 1 == 1
The following test sample:
import pytest
class DescribeHouse:
def it_has_door(self):
assert 1 == 1
class WithTwoFloors:
def it_has_stairs(self):
assert 1 == 1
def it_has_second_floor(self):
assert 1 == 1
def it_has_third_floor(self):
assert 1 == 2
Generates the following output:
test/test_sample.py
A house
✓ has door
A house
with two floors
✓ has stairs
✓ has second floor
✗ has third floor
Installing and running pySpec
pip install pytest pytest-pyspec
pytest --pyspec
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest_pyspec-0.10.0.tar.gz
.
File metadata
- Download URL: pytest_pyspec-0.10.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
72df3c0e853e25ab2484d059f1bebef3e2af88f346a99c16c4095a7a91a66441
|
|
MD5 |
5863a796ad065b5a87f1c233192614e1
|
|
BLAKE2b-256 |
056679da694967173baa665423ebe3e3dce58143119d0f5d7dd3bad74e4a55da
|
File details
Details for the file pytest_pyspec-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_pyspec-0.10.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/5.15.133.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
68bdd21a9e5d2fe8ee8be2b5ff72d58fc7b8d2226f6c0dae49973e35c766fafd
|
|
MD5 |
8ef5a414b8b8e6e95d51db6bc12dd648
|
|
BLAKE2b-256 |
3bf90a915633bf3bb1a6380e6f22577ad7c6a1c3618ccbf7d7130e306c834cba
|