Skip to content

Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.

License

Notifications You must be signed in to change notification settings

yk-kd/pytest-spec

 
 

Repository files navigation

pytest-spec

Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.

Available features

  • Format output to look like specification.
  • Group tests by classes and files
  • Failed, passed and skipped are marked and colored.
  • Remove test_ and underscores for every test.
  • It is possible to use docstring summary instead of test name.
  • Supports function based, class based test.
  • Supports describe like tests.

Output example

Example

Configuration

spec_header_format

You can configure the format of the test headers by specifying a format string in your ini-file:

    ; since pytest 4.6.x
    [pytest]
    spec_header_format = {module_path}:
    
    ; legacy pytest
    [tool:pytest]
    spec_header_format = {module_path}:

In addition to the {path} and {class_name} replacement fields, there is also {test_case} that holds a more human readable name.

spec_test_format

You can configure the format of the test results by specifying a format string in your ini-file:

3 variables are available:

  • result - place for indicator
  • name - name of test
  • docstring_summary - first line from test docstring if available
    ; since pytest 4.6.x
    [pytest]
    spec_test_format = {result} {name}
    
    ; legacy pytest
    [tool:pytest]
    spec_test_format = {result} {name}

or

    ; since pytest 4.6.x
    [pytest]
    spec_test_format = {result} {docstring_summary}
    
    ; legacy pytest
    [tool:pytest]
    spec_test_format = {result} {docstring_summary}

In second example where docstring is not available the name will be added to spec output.

spec_success_indicator

You can configure the indicator displayed when test passed.

    ; since pytest 4.6.x
    [pytest]
    spec_success_indicator = ✓

    ; legacy pytest
    [tool:pytest]
    spec_success_indicator = ✓

spec_failure_indicator

You can configure the indicator displated when test failed.

    ; since pytest 4.6.x
    [pytest]
    spec_failure_indicator = ✗

    ; legacy pytest
    [tool:pytest]
    spec_failure_indicator = ✗

spec_skipped_indicator

You can configure the indicator displated when test is skipped.

    ; since pytest 4.6.x
    [pytest]
    spec_skipped_indicator = ?

    ; legacy pytest
    [tool:pytest]
    spec_skipped_indicator = ?

spec_ignore

Comma-separated settings to ignore/hide some tests or output from from plugins like FLAKE8 or ISORT. Any test which contain provided string will be ignored in output spec.

    ; since pytest 4.6.x
    [pytest]
    spec_ignore = FLAKE8

    ; legacy pytest
    [tool:pytest]
    spec_ignore = FLAKE8

spec_indent

    ; since pytest 4.6.x
    [pytest]
    spec_indent = "   "

    ; legacy pytest
    [tool:pytest]
    spec_indent = "   "

Continuous Integration

Tests

Download

All versions of library are available on official pypi server.

Install

    pip install pytest-spec

Contribution

Please feel free to present your idea by code example (pull request) or reported issues.

Contributors

License

pytest-spec - pytest plugin to display test execution output like a SPECIFICATION.

Copyright (C) 2014-2021 Pawel Chomicki

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

About

Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%