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 TestHouse:
"a House"
def test_door(self):
"has door"
assert 1 == 1
class TestTwoFloors:
"""with two floors
A house with two floor has stairs
"""
def test_stairs(self):
"has stairs"
assert 1 == 1
def test_second_floor(self):
"has second floor"
assert 1 == 1
def test_third_floor(self):
"has third floor"
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
Hashes for pytest_pyspec-0.8.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 915f82f311eda44004bfcd354f3121c99bc34e08caf6e179e8a35b466b328fde |
|
MD5 | ea84a5d07b74f675a0b4c022a23ddb90 |
|
BLAKE2b-256 | 05ff19aa50393b2dd9732fc3281c27cac11619923ef60e181a35587626025e83 |