-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathutil.py
49 lines (34 loc) · 1.02 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from typing import Any
from pytest import mark, param
def fails(arg: Any, reason: str = "No reason given") -> Any:
"""Mark a parameter for pytest parametrize that it should fail
..code:: python
@parametrize("number", [2, 3, fails(5, "some reason")])
Parameters
----------
arg : Any
The arg that should fail
reason : str = "No reason given"
The reason for the expected fail
Returns
-------
Any
The param object
"""
return param(arg, marks=mark.xfail(reason=reason))
def skip(arg: Any, reason: str = "No reason given") -> Any:
"""Mark a parameter for pytest parametrize that should be skipped
..code:: python
@parametrize("number", [2, 3, skip(5, "some reason")])
Parameters
----------
arg : Any
The arg that should be skipped
reason : str = "No Reason given"
The reason for skipping it
Returns
-------
Any
The param object
"""
return param(arg, marks=mark.skip(reason=reason))