Skip to content

Declare pytest marks for your unit tests in yml/json files next to your source code without decorators!

Notifications You must be signed in to change notification settings

tonydelanuez/pytest-test-marker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pytest-test-marker

This package gives you the ability to define your pytest markers in a configuration file via YAML/JSON. You can use this tool to mark individual test functions, classes, or entire modules with a custom pytest marker.

Rather than wrapping individual functions or classes with the @pytest.mark.foo decorator, declare your markers alongside of your code for easy updating / keeping track of large lists of markers.

pytest-test-marker is tested on Python 2.7, 3.6, 3.7, 3.8, and 3.9

Usage:

Declare a pytest marker file in either YAML or JSON

pytest_markers.yaml:

example_marker:
    modules:
        - src / test2.py
    classes:
        - src/test0.py::ExampleTestCase1
    functions:
        - src/test1.py::ExampleTestCase2::ex_test_func_2
        - tests/test_mark.py::test_collection_modifier_init_markdefs

pytest_markers.json:

{
    "example_marker": {
        "modules": [
            "src/test2.py"
        ],
        "classes": [
            "src/test0.py::ExampleTestCase1"
        ],
        "functions": [
            "src/test1.py::ExampleTestCase2::ex_test_func_2"
        ]
    }
}

Install the plugin: pip install pytest-test-marker

When invoking pytest, use the --mark-file option (as well as any markers you want checked in your test run): pytest /path/to/tests --mark-file pytest_markers.yml

About

Declare pytest marks for your unit tests in yml/json files next to your source code without decorators!

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages