pytest-collect-formatter
Pytest plugin for formatting output of the collected tests.
Free software: MIT license
Requirements
pyyaml
dicttoxml
Installation
You can install “pytest-collect-formatter” via pip:
$ pip install pytest-collect-formatter
Usage
Use this plugin by running pytest normally and use the following options to customize collection format, it’s better to use with –collect-only option
>>> collect-formatter:
--collect-output-file=COLLECT_OUTPUT_FILE
Saves collected test items to the file
--collect-format=COLLECT_FORMAT
Saves collected test items specified format [xml, yaml, json]
--collect-type=COLLECT_TYPE
Format output results in classic pytest view or in 'path' view [classic, path], default classic
Example of usage
$ pytest tests –collect-output-file my_tests_structure.xml –collect-format xml
And you will get the my_tests_structure.xml
Exmpales of formats
PATH
JSON
[
{
"type": "path",
"title": "examples",
"children": [
{
"type": "path",
"title": "tests",
"children": [
{
"type": "path",
"title": "test_formatter",
"children": [
{
"type": "path",
"title": "test_fromatter_v1.py",
"children": [
{
"type": "pytest_unit",
"title": "TestFormatter",
"children": [
{
"type": "pytest_unit",
"title": "test_inside_class",
"children": []
},
{
...
YAML
- children:
- children:
- children:
- children:
- children:
- children: []
title: test_inside_class
type: pytest_unit
- children: []
title: test_inside_class_parametrize[1]
type: pytest_unit
- children: []
title: test_inside_class_parametrize[2]
type: pytest_unit
- children: []
title: test_inside_class_parametrize[3]
...
XML
<?xml version="1.0" ?>
<root>
<item>
<type>path</type>
<title>examples</title>
<children>
<item>
<type>path</type>
<title>tests</title>
<children>
<item>
<type>path</type>
<title>test_formatter</title>
<children>
<item>
<type>path</type>
<title>test_fromatter_v1.py</title>
<children>
<item>
<type>pytest_unit</type>
<title>TestFormatter</title>
<children>
<item>
<type>pytest_unit</type>
<title>test_inside_class</title>
<children/>
</item>
...
CLASSIC
JSON
[
{
"type": "Package",
"value": "test_formatter",
"children": [
{
"type": "Module",
"value": "test_fromatter_v1.py",
"children": [
{
"type": "Class",
"value": "TestFormatter",
"children": [
{
"type": "Function",
"value": "test_inside_class"
}
....
YAML
- children:
- children:
- children:
- type: Function
value: test_inside_class
- type: Function
value: test_inside_class_parametrize[1]
- type: Function
value: test_inside_class_parametrize[2]
- type: Function
value: test_inside_class_parametrize[3]
- type: Function
value: test_inside_class_parametrize[4]
type: Class
value: TestFormatter
- type: Function
value: test_outside_of_class
type: Module
value: test_fromatter_v1.py
type: Package
value: test_formatter
....
XML
<?xml version="1.0" ?>
<root>
<item>
<type>Package</type>
<value>test_formatter</value>
<children>
<item>
<type>Module</type>
<value>test_fromatter_v1.py</value>
<children>
<item>
<type>Class</type>
<value>TestFormatter</value>
<children>
<item>
<type>Function</type>
<value>test_inside_class</value>
</item>
<item>
<type>Function</type>
<value>test_inside_class_parametrize[1]</value>
</item>
<item>
<type>Function</type>
<value>test_inside_class_parametrize[2]</value>
</item>
<item>
<type>Function</type>
<value>test_inside_class_parametrize[3]</value>
</item>
<item>
<type>Function</type>
<value>test_inside_class_parametrize[4]</value>
</item>
</children>
</item>
<item>
<type>Function</type>
<value>test_outside_of_class</value>
</item>
</children>
</item>
</children>
....
More examples could be found in examples folder as well as tests structure
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
Credits
Development Lead
Contributors
Metadata
Release files for pytest-collect-formatter 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest-collect-formatter-0.4.0.tar.gz | 6.8 kB | Without provenance | Details for pytest-collect-formatter-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_collect_formatter-0.4.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pytest_collect_formatter-0.4.0-py2.py3-none-any.whl |
Total release size: 12.6 kB
Release files / pytest-collect-formatter-0.4.0.tar.gz
| Download URL | pytest-collect-formatter-0.4.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d8a77aa7e71ed9745b1c2017248d9ee4b1188619a9d268b34db714af03a140a
|
|
BLAKE2b-256 checksum How to use checksums |
282fd7db868750d6c8a1d2779c1b5d34e50aa7c37c6b8b98ddf38e345c6cb288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / pytest_collect_formatter-0.4.0-py2.py3-none-any.whl
| Download URL | pytest_collect_formatter-0.4.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9f4273cb688d818de2a022bef56e5ec5a93c07fdeacab86712cf2d3adf19802d
|
|
BLAKE2b-256 checksum How to use checksums |
713c612fedc2a34913e3acde31d322a0c895b380da8cea708d18d4973482bc4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for pytest-collect-formatter 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.