1
1
import inspect
2
+ import re
2
3
3
4
import pytest
4
5
from pytest_mock import MockerFixture
@@ -23,7 +24,12 @@ def test_get_full_key_valid_arguments(args_kwargs_signature):
23
24
24
25
def test_get_full_key_invalid_key_format (args_kwargs_signature ):
25
26
bound_args = args_kwargs_signature .bind ('value1' , 'value2' )
26
- with pytest .raises (ValueError , match = 'Arguments in a key do not match function signature' ):
27
+ bound_args .apply_defaults ()
28
+
29
+ with pytest .raises (
30
+ ValueError ,
31
+ match = re .escape (f'Arguments in a key(key_{{}}_{{}}_{{}}) do not match function signature params({ bound_args } )' ),
32
+ ):
27
33
get_full_key_from_signature (bound_args , 'key_{}_{}_{}' )
28
34
29
35
@@ -35,8 +41,16 @@ def test_get_full_key_empty_key_and_arguments(args_kwargs_signature):
35
41
36
42
def test_get_full_key_mixed_placeholders (args_kwargs_signature ):
37
43
bound_args = args_kwargs_signature .bind ('value1' , 'value2' , arg3 = 'value3' )
38
- with pytest .raises (ValueError , match = 'Arguments in a key do not match function signature' ):
39
- get_full_key_from_signature (bound_args , 'key_{}_{}_{}_{invalid_arg}' )
44
+ bound_args .apply_defaults ()
45
+
46
+ with pytest .raises (
47
+ ValueError ,
48
+ match = re .escape (
49
+ 'Arguments in a key(key_{}_{}_{}_{invalid_arg}) '
50
+ + f'do not match function signature params({ bound_args } )'
51
+ ),
52
+ ):
53
+ _ = get_full_key_from_signature (bound_args , 'key_{}_{}_{}_{invalid_arg}' )
40
54
41
55
42
56
def test_reset_calls_delete_with_key (init_cachify_fixture , args_kwargs_signature , mocker : MockerFixture ):
0 commit comments