Skip to content

Commit 8db95e1

Browse files
authored
Document record_property usage (#23)
Issue #7 document usage of `record_property` fixture
1 parent 6af929d commit 8db95e1

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
tox_env: "py39"
2626

2727
steps:
28-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v3
2929
- name: Set up Python
30-
uses: actions/setup-python@v1
30+
uses: actions/setup-python@v4
3131
with:
3232
python-version: ${{ matrix.python }}
3333
- name: Install tox
@@ -43,9 +43,9 @@ jobs:
4343
runs-on: ubuntu-latest
4444

4545
steps:
46-
- uses: actions/checkout@v1
46+
- uses: actions/checkout@v3
4747
- name: Set up Python
48-
uses: actions/setup-python@v1
48+
uses: actions/setup-python@v4
4949
with:
5050
python-version: "3.7"
5151
- name: Install tox
@@ -64,9 +64,9 @@ jobs:
6464
needs: [build, linting]
6565

6666
steps:
67-
- uses: actions/checkout@v1
67+
- uses: actions/checkout@v3
6868
- name: Set up Python
69-
uses: actions/setup-python@v1
69+
uses: actions/setup-python@v4
7070
with:
7171
python-version: "3.7"
7272
- name: Install wheel

README.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Replacement for the ``--resultlog`` option, focused in simplicity and extensibil
3030
Usage
3131
=====
3232

33+
Install ``pytest-reportlog`` as a test requirement in your test environment.
34+
3335
The ``--report-log=FILE`` option writes *report logs* into a file as the test session executes.
3436

3537
Each line of the report log contains a self contained JSON object corresponding to a testing event,
@@ -91,6 +93,28 @@ The generated ``log.json`` will contain a JSON object per line:
9193
{"nodeid": "test_report_example.py::test_fail", "location": ["test_report_example.py", 4, "test_fail"], "keywords": {"test_fail": 1, "pytest-reportlog": 1, "test_report_example.py": 1}, "outcome": "passed", "longrepr": null, "when": "teardown", "user_properties": [], "sections": [], "duration": 0.0, "$report_type": "TestReport"}
9294
{"exitstatus": 1, "$report_type": "SessionFinish"}
9395

96+
97+
record_property
98+
---------------
99+
100+
The ``record_property`` fixture allows to log additional information for a test, just like with JUnitXML format.
101+
Consider this test file:
102+
103+
.. code-block:: python
104+
105+
def test_function(record_property):
106+
record_property("price", 12.34)
107+
record_property("fruit", "banana")
108+
assert True
109+
110+
This information will be recorded in the report JSON objects under the ``user_properties`` key as follows::
111+
112+
..., "user_properties": [["price", 12.34], ["fruit", "banana"]], ...
113+
114+
Note that this nested list construct is just the JSON representation
115+
of a list of tuples (name-value pairs).
116+
117+
94118
License
95119
=======
96120

0 commit comments

Comments
 (0)