File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ files = [
126126 " mocket/utils.py" ,
127127 " mocket/plugins/httpretty/__init__.py" ,
128128 " tests/test_httpretty.py" ,
129+ " tests/test_mocket_utils.py" ,
129130 # "tests/"
130131 ]
131132strict = true
Original file line number Diff line number Diff line change 1+ from typing import Callable
2+ from unittest import TestCase
3+ from unittest .mock import NonCallableMock , patch
4+
5+ import decorator
6+
7+ from mocket .utils import get_mocketize
8+
9+
10+ def mock_decorator (func : Callable [[], None ]) -> None :
11+ return func ()
12+
13+
14+ class GetMocketizeTestCase (TestCase ):
15+ @patch .object (decorator , "decorator" )
16+ def test_get_mocketize_with_kwsyntax (self , dec : NonCallableMock ) -> None :
17+ get_mocketize (mock_decorator )
18+ dec .assert_called_once_with (mock_decorator , kwsyntax = True )
19+
20+ @patch .object (decorator , "decorator" )
21+ def test_get_mocketize_without_kwsyntax (self , dec : NonCallableMock ) -> None :
22+ dec .side_effect = [
23+ TypeError ("kwsyntax is not supported in this version of decorator" ),
24+ mock_decorator ,
25+ ]
26+
27+ get_mocketize (mock_decorator )
28+ # First time called with kwsyntax=True, which failed with TypeError
29+ dec .call_args_list [0 ].assert_compare_to ((mock_decorator ,), {"kwsyntax" : True })
30+ # Second time without kwsyntax, which succeeds
31+ dec .call_args_list [1 ].assert_compare_to ((mock_decorator ,))
You can’t perform that action at this time.
0 commit comments