Skip to content

Commit 19deb1c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
1 parent cb35c54 commit 19deb1c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

stdlib/@tests/test_cases/check_unittest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from fractions import Fraction
88
from typing import TypedDict
99
from typing_extensions import assert_type
10-
from unittest.mock import MagicMock, Mock, patch, AsyncMock
10+
from unittest.mock import AsyncMock, MagicMock, Mock, patch
1111

1212
case = unittest.TestCase()
1313

@@ -153,17 +153,20 @@ def f_default_new(i: int, mock: MagicMock) -> str:
153153
def f_explicit_new(i: int) -> str:
154154
return "asdf"
155155

156+
156157
@patch("sys.exit", new_callable=lambda: 42)
157158
def f_explicit_new_callable(i: int, new_callable_ret: int) -> str:
158159
return "asdf"
159160

161+
160162
assert_type(f_default_new(1), str)
161163
f_default_new("a") # Not an error due to ParamSpec limitations
162164
assert_type(f_explicit_new(1), str)
163165
f_explicit_new("a") # type: ignore[arg-type]
164166
assert_type(f_explicit_new_callable(1), str)
165167
f_explicit_new_callable("a") # Same as default new
166168

169+
167170
@patch("sys.exit", new=Mock())
168171
class TestXYZ(unittest.TestCase):
169172
attr: int = 5
@@ -191,6 +194,7 @@ def method() -> int:
191194
# Tests for mock.patch.object
192195
###
193196

197+
194198
@patch.object(Decimal, "exp")
195199
def obj_f_default_new(i: int, mock: MagicMock) -> str:
196200
return "asdf"
@@ -200,10 +204,12 @@ def obj_f_default_new(i: int, mock: MagicMock) -> str:
200204
def obj_f_explicit_new(i: int) -> str:
201205
return "asdf"
202206

207+
203208
@patch.object(Decimal, "exp", new_callable=lambda: 42)
204209
def obj_f_explicit_new_callable(i: int, new_callable_ret: int) -> str:
205210
return "asdf"
206211

212+
207213
assert_type(obj_f_default_new(1), str)
208214
obj_f_default_new("a") # Not an error due to ParamSpec limitations
209215
assert_type(obj_f_explicit_new(1), str)
@@ -212,7 +218,6 @@ def obj_f_explicit_new_callable(i: int, new_callable_ret: int) -> str:
212218
obj_f_explicit_new_callable("a") # Same as default new
213219

214220

215-
216221
with patch.object(Decimal, "exp") as obj_default_new_enter:
217222
assert_type(obj_default_new_enter, MagicMock | AsyncMock)
218223

0 commit comments

Comments
 (0)