Formatter for pytest collect output
Project description
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]
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
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
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-collect-formatter-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-collect-formatter-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f098acaf2012a5ff80866b7c5143f27bfe57061d7d12ac4504ae48b310addbeb |
|
MD5 | 7e8319ed4a9fc7ca5d339ab4aeeb87b4 |
|
BLAKE2b-256 | cbca7de1a7f1a37bc63b3732f62d1f5cd9e5547f181706ed865e3ff127bbb0b3 |
File details
Details for the file pytest_collect_formatter-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_collect_formatter-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a101b03d946ed8b73449a7c8e5b9cbc42a9a0cada65c31b574ed1503a4cf730 |
|
MD5 | c62416d638720cfdb14f1818768dce74 |
|
BLAKE2b-256 | 1f2e0371c985848300961779189c7fbdae402e5c517cd230bdaacaf58d436de1 |