Display more node information.
- pytest >= 3.10.0
- python >= 3.6
Not compatible with Python2.x
$ pip install pytest-informative-node
# pytest.ini
[pytest]
[informative_node_id]
enable : true
delimiter : @
write docstring with leading delimiter
you defined in pytest.ini [informative_node_id]
section as node name.
class TestClass:
"""@you node id"""
def test_func():
"""@you node id"""
Test file and Test Package is also supported, just write docstring in the top of file and
__init__.py
respectively.
Notice!
[pytest]
section must be included.
Notice! All options bellow must be under[informative_node_id]
section inpytest.ini
.
enable
: [true / false] default isfalse
.delimiter
: the delimiter to extract node_id in docstring, default is@
.
# Test file structure
scenario
|
|__functionality
|__ __init__.py
| |# content of __init__.py
| |"""@LoginSection"""
| #\---------------------
|
|__ test_one.py
|# content of __init__.py
| """@TestFile"""
| import pytest
| class TestClass:
| """@TestGroup"""
|
| @pytest.mark.parametrize('n', [1, 2], ids=['first', 'second'])
| def test_demo(self, n):
| """@DemoTest"""
| assert n == 1
#\-----------------------
# Test report structure
✕LoginSection
|
|__ ✕TestFile
|
|__ ✕TestGroup
|
|__ ✕Demo Test
|__ ✓first
|__ ✕second
Notice: Duplicate custom node id under same test level is not allowed.
e.g.
def test_a():
"""@ login"""
def test_b():
"""@ login""" # <-----XXXXXX!
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
Distributed under the terms of the MIT license, "pytest-informative-node" is free and open source software
- If you test with Pycharm, you cannot navigate back to source test file from Test Runner tab.