Move errors patterns and check functions to testlib

Signed-off-by: Aleksei Chetaev <alex.chetaev@gmail.com>
This commit is contained in:
Aleksei Chetaev 2023-02-17 14:00:16 +01:00 committed by Aleksey Chetaev
parent e891f3804c
commit 44e9a8480a
3 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,11 @@
import re
def error_matches_status(error: Exception, status_pattern: str) -> bool:
"""
Determines whether exception matches specified status pattern.
We use re.search() to be consistent with pytest.raises.
"""
match = re.search(status_pattern, str(error))
return match is not None