Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c93e8e

Browse files
committed
feat: to rst:1433
1 parentf3cd41e commit1c93e8e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

‎library/unittest.mock.po

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version:Python 3.12\n"
88
"Report-Msgid-Bugs-To:\n"
99
"POT-Creation-Date:2023-12-16 00:03+0000\n"
10-
"PO-Revision-Date:2024-01-09 23:08+0800\n"
10+
"PO-Revision-Date:2024-01-11 22:02+0800\n"
1111
"Last-Translator:Adrian Liaw <adrianliaw2000@gmail.com>\n"
1212
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
@@ -1087,7 +1087,7 @@ msgstr ""
10871087
msgid""
10881088
"If any members of the iterable are exceptions they will be raised instead of "
10891089
"returned::"
1090-
msgstr"如果可疊代物件中的任何成員是例外,則它們將被引發而不是被回傳:"
1090+
msgstr"如果可疊代物件中的任何成員是例外,則它們將被引發而不是被回傳: ::"
10911091

10921092
#:../../library/unittest.mock.rst:1220
10931093
msgid"Deleting Attributes"
@@ -1326,6 +1326,8 @@ msgid ""
13261326
"If you are patching builtins in a module then you don't need to pass "
13271327
"``create=True``, it will be added by default."
13281328
msgstr""
1329+
"如果你正在 patch 模組中的內建函式,那麼你不需要傳遞 ``create=True``,它預設會"
1330+
"被加入。"
13291331

13301332
#:../../library/unittest.mock.rst:1396
13311333
msgid""
@@ -1337,6 +1339,11 @@ msgid ""
13371339
"tests. You can specify an alternative prefix by setting ``patch."
13381340
"TEST_PREFIX``."
13391341
msgstr""
1342+
"patch 可以做為 :class:`TestCase` 類別的裝飾器使用。它透過裝飾類別中的每個測試"
1343+
"方法來運作。當你的測試方法共享一組常見的 patch 時,這會減少繁冗的代碼。:func:"
1344+
"`patch` 通過搜尋以 ``patch.TEST_PREFIX`` 開頭的方法名來尋找測試。預設情況下會"
1345+
"是 ``'test'``,這與 :mod:`unittest` 尋找測試的方式相匹配。你可以通過設定 "
1346+
"``patch.TEST_PREFIX`` 來指定別的前綴。"
13401347

13411348
#:../../library/unittest.mock.rst:1403
13421349
msgid""
@@ -1345,45 +1352,60 @@ msgid ""
13451352
"\"as\" then the patched object will be bound to the name after the\"as\"; "
13461353
"very useful if :func:`patch` is creating a mock object for you."
13471354
msgstr""
1355+
"透過 with 陳述式,Patch 可以做為情境管理器使用。 這裡,patch 適用於 with 陳述"
1356+
"式之後的縮排區塊。 如果你使用 “as”,則被 patch 的物件將被綁定到 “as” 後面的名"
1357+
"稱; 如果 :func:`patch` 正在為你建立一個 mock 物件,這會非常有用。"
13481358

13491359
#:../../library/unittest.mock.rst:1408
13501360
msgid""
13511361
":func:`patch` takes arbitrary keyword arguments. These will be passed to :"
13521362
"class:`AsyncMock` if the patched object is asynchronous, to :class:"
13531363
"`MagicMock` otherwise or to *new_callable* if specified."
13541364
msgstr""
1365+
":func:`patch` 接受任意的關鍵字引數。 如果被 patch 的物件是非同步的,這些將會"
1366+
"被傳遞給 :class:`AsyncMock`,如果是同步的則會傳遞給 :class:`MagicMock`,或如"
1367+
"果指定了 *new_callable*,則傳遞給它。"
13551368

13561369
#:../../library/unittest.mock.rst:1412
13571370
msgid""
13581371
"``patch.dict(...)``, ``patch.multiple(...)`` and ``patch.object(...)`` are "
13591372
"available for alternate use-cases."
13601373
msgstr""
1374+
"``patch.dict(...)``、``patch.multiple(...)`` 和 ``patch.object(...)`` 可用於"
1375+
"其餘的使用情境。"
13611376

13621377
#:../../library/unittest.mock.rst:1415
13631378
msgid""
13641379
":func:`patch` as function decorator, creating the mock for you and passing "
13651380
"it into the decorated function::"
13661381
msgstr""
1382+
":func:`patch` 作為函式裝飾器,為你建立 mock 並將其傳遞給被裝飾的函式: ::"
13671383

13681384
#:../../library/unittest.mock.rst:1425
13691385
msgid""
13701386
"Patching a class replaces the class with a :class:`MagicMock` *instance*. If "
13711387
"the class is instantiated in the code under test then it will be the :attr:"
13721388
"`~Mock.return_value` of the mock that will be used."
13731389
msgstr""
1390+
"Patch 一個類別會以 :class:`MagicMock` *實例*取代該類別。 如果該類別在被測試的"
1391+
"程式碼中實例化,那麼它將是會被使用的 mock 的:attr:`~Mock.return_value`。"
13741392

13751393
#:../../library/unittest.mock.rst:1429
13761394
msgid""
13771395
"If the class is instantiated multiple times you could use :attr:`~Mock."
13781396
"side_effect` to return a new mock each time. Alternatively you can set the "
13791397
"*return_value* to be anything you want."
13801398
msgstr""
1399+
"如果該類別被實例化多次,你可以使用:attr:`~Mock.side_effect` 來每次回傳一個新"
1400+
"的 mock。 或者你可以將 *return_value* 設定成你想要的任何值。"
13811401

13821402
#:../../library/unittest.mock.rst:1433
13831403
msgid""
13841404
"To configure return values on methods of *instances* on the patched class "
13851405
"you must do this on the :attr:`return_value`. For example::"
13861406
msgstr""
1407+
"若要配置被 patch 的類別的*實例*方法的回傳值,你必須在 :attr:`return_value`上"
1408+
"進行配置。 例如: ::"
13871409

13881410
#:../../library/unittest.mock.rst:1447
13891411
msgid""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp