Skip to main content

Formatter for pytest collect output

Project description

======================== pytest-collect-formatter2

Fork From: https://github.com/LaserPhaser/pytest-collect-formatter

add remark collect

Pytest plugin for formatting output of the collected tests.

  • Free software: MIT license

Requirements

  • pyyaml
  • dicttoxml

Installation

You can install "pytest-collect-formatter2" via pip_::

$ pip install pytest-collect-formatter2

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 --with-remark Collect method remark,priority: 1st-@allure.title() 2nd-method python doc 3rd- method comment

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

.. code-block::

[
    {
        "type": "Module",
        "title": "examples/tests/test_formatter/test_fromatter_v1.py",
        "children": [
            {
                "type": "Class",
                "title": "TestFormatter",
                "children": [
                    {
                        "type": "Function",
                        "title": "test_inside_class",
                        "remark": "this is remark"
                    },
                    {
                        "type": "Function",
                        "title": "test_inside_class_parametrize[1]",
                        "remark": null
                    },
                    {
                        "type": "Function",
                        "title": "test_inside_class_parametrize[2]",
                        "remark": null
                    },
                    {
                        "type": "Function",
                        "title": "test_inside_class_parametrize[3]",
                        "remark": null
                    },
                    {
                        "type": "Function",
                        "title": "test_inside_class_parametrize[4]",
                        "remark": null
                    }
                ],
                "remark": null
            },
            {
                "type": "Function",
                "title": "test_outside_of_class",
                "remark": "this is remark 3"
            }
        ],
        "remark": null
    }
]

YAML

.. code-block::

- 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

.. code-block::

<?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

.. code-block::

[ { "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

.. code-block::

- 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

.. code-block::

<?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

.. _file an issue: https://github.com/pytest-dev/pytest-slack/issues .. _pip: https://pypi.python.org/pypi/pip/

======= Credits

Development Lead

  • Laser <https://github.com/LaserPhaser>_

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-collect-formatter2-0.1.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytest_collect_formatter2-0.1.2-py3.8.egg (4.9 kB view details)

Uploaded Egg

pytest_collect_formatter2-0.1.2-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-collect-formatter2-0.1.2.tar.gz.

File metadata

  • Download URL: pytest-collect-formatter2-0.1.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for pytest-collect-formatter2-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5ef755d69f8c3c855e84d0d57ad34812f760069bd1138589de85061ad5b206e2
MD5 f86d75b67a8d9e5b6b8836371a3182d2
BLAKE2b-256 057f585f36f8e503edc98b3d3b10390c7b41f361efea86bbba90ac9c1ecbf988

See more details on using hashes here.

File details

Details for the file pytest_collect_formatter2-0.1.2-py3.8.egg.

File metadata

  • Download URL: pytest_collect_formatter2-0.1.2-py3.8.egg
  • Upload date:
  • Size: 4.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for pytest_collect_formatter2-0.1.2-py3.8.egg
Algorithm Hash digest
SHA256 4e4f25665a073b1afb790bb36837a29472581812ffbb16edd14ea98f1e27136d
MD5 1bc7d6084cab24f8f4e9c1814f8a3cc3
BLAKE2b-256 472b5a8fa9a15d944185bd9ec1b73a81670c6e02828a692c4af9bcb2f87ce83a

See more details on using hashes here.

File details

Details for the file pytest_collect_formatter2-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_collect_formatter2-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for pytest_collect_formatter2-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2f7207060bba574de5d3a67f881750911cc5eb4121f0a3bfe8f59347a718eaea
MD5 72d4edd7e75afa5b8d008ec501bcc1ff
BLAKE2b-256 6a9f2240f0e02bfbffd72769ff10ce5bb500492f532e5258ce5edf291461fb20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page