MCPcopy Create free account
hub / github.com/NVIDIA/DALI / get_pattern

Function get_pattern

dali/test/python/nose_utils.py:71–92  ·  view source on GitHub ↗
(glob=None, regex=None, match_case=None)

Source from the content-addressed store, hash-verified

69
70
71def get_pattern(glob=None, regex=None, match_case=None):
72 assert glob is not None or regex is not None
73
74 if glob is not None and regex is not None:
75 raise ValueError(
76 "You should specify at most one of `glob` and `regex` parameters but not both"
77 )
78
79 if glob is not None:
80 pattern = glob_to_regex(glob)
81 else: # regex is not None
82 if match_case is not None and not isinstance(regex, str):
83 raise ValueError(
84 "Regex must be a string if `match_case` is specified when "
85 "calling assert_raises_pattern"
86 )
87 pattern = regex
88
89 if isinstance(pattern, str) and not match_case: # ignore case by default
90 pattern = re.compile(pattern, re.IGNORECASE)
91
92 return pattern
93
94
95def assert_raises(exception, *args, glob=None, regex=None, match_case=None, **kwargs):

Callers 2

assert_raisesFunction · 0.85
assert_warnsFunction · 0.85

Calls 1

glob_to_regexFunction · 0.85

Tested by

no test coverage detected