Pytest: Deselecting tests

后端 未结 5 875
臣服心动
臣服心动 2021-01-31 07:28

With pytest, one can mark tests using a decorator

@pytest.mark.slow
def some_slow_test():
    pass

Then, from the command line, one can tell py

5条回答
  •  执念已碎
    2021-01-31 08:26

    Is your test correctly written? Normally, tests start with test_? But anyway, it depended on what you try to filter, you can filter those tests by name using -k "not slow and not long" or by tag using -m "not slow and not long".

    Run tests by keyword expressions

    -k: This will run tests which contain names that match the given string expression (case-insensitive), which can include Python operators that use filenames, class names and function names as variables.

    Run tests by marker expressions

    -m: Will run all tests which are decorated with the @pytest.mark.slow decorator.

    More documentation info can be found on:

    • https://docs.pytest.org/en/latest/usage.html
    • Or do: pytest --help

提交回复
热议问题