@@ -7,7 +7,7 @@ msgstr ""
7
7
"Project-Id-Version :Python 3.12\n "
8
8
"Report-Msgid-Bugs-To :\n "
9
9
"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 "
11
11
"Last-Translator :Adrian Liaw <adrianliaw2000@gmail.com>\n "
12
12
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -1087,7 +1087,7 @@ msgstr ""
1087
1087
msgid ""
1088
1088
"If any members of the iterable are exceptions they will be raised instead of "
1089
1089
"returned::"
1090
- msgstr "如果可疊代物件中的任何成員是例外,則它們將被引發而不是被回傳:"
1090
+ msgstr "如果可疊代物件中的任何成員是例外,則它們將被引發而不是被回傳: :: "
1091
1091
1092
1092
#: ../../library/unittest.mock.rst:1220
1093
1093
msgid "Deleting Attributes"
@@ -1326,6 +1326,8 @@ msgid ""
1326
1326
"If you are patching builtins in a module then you don't need to pass "
1327
1327
"``create=True``, it will be added by default."
1328
1328
msgstr ""
1329
+ "如果你正在 patch 模組中的內建函式,那麼你不需要傳遞 ``create=True``,它預設會"
1330
+ "被加入。"
1329
1331
1330
1332
#: ../../library/unittest.mock.rst:1396
1331
1333
msgid ""
@@ -1337,6 +1339,11 @@ msgid ""
1337
1339
"tests. You can specify an alternative prefix by setting ``patch."
1338
1340
"TEST_PREFIX``."
1339
1341
msgstr ""
1342
+ "patch 可以做為 :class:`TestCase` 類別的裝飾器使用。它透過裝飾類別中的每個測試"
1343
+ "方法來運作。當你的測試方法共享一組常見的 patch 時,這會減少繁冗的代碼。:func:"
1344
+ "`patch` 通過搜尋以 ``patch.TEST_PREFIX`` 開頭的方法名來尋找測試。預設情況下會"
1345
+ "是 ``'test'``,這與 :mod:`unittest` 尋找測試的方式相匹配。你可以通過設定 "
1346
+ "``patch.TEST_PREFIX`` 來指定別的前綴。"
1340
1347
1341
1348
#: ../../library/unittest.mock.rst:1403
1342
1349
msgid ""
@@ -1345,45 +1352,60 @@ msgid ""
1345
1352
"\" as\" then the patched object will be bound to the name after the\" as\" ; "
1346
1353
"very useful if :func:`patch` is creating a mock object for you."
1347
1354
msgstr ""
1355
+ "透過 with 陳述式,Patch 可以做為情境管理器使用。 這裡,patch 適用於 with 陳述"
1356
+ "式之後的縮排區塊。 如果你使用 “as”,則被 patch 的物件將被綁定到 “as” 後面的名"
1357
+ "稱; 如果 :func:`patch` 正在為你建立一個 mock 物件,這會非常有用。"
1348
1358
1349
1359
#: ../../library/unittest.mock.rst:1408
1350
1360
msgid ""
1351
1361
":func:`patch` takes arbitrary keyword arguments. These will be passed to :"
1352
1362
"class:`AsyncMock` if the patched object is asynchronous, to :class:"
1353
1363
"`MagicMock` otherwise or to *new_callable* if specified."
1354
1364
msgstr ""
1365
+ ":func:`patch` 接受任意的關鍵字引數。 如果被 patch 的物件是非同步的,這些將會"
1366
+ "被傳遞給 :class:`AsyncMock`,如果是同步的則會傳遞給 :class:`MagicMock`,或如"
1367
+ "果指定了 *new_callable*,則傳遞給它。"
1355
1368
1356
1369
#: ../../library/unittest.mock.rst:1412
1357
1370
msgid ""
1358
1371
"``patch.dict(...)``, ``patch.multiple(...)`` and ``patch.object(...)`` are "
1359
1372
"available for alternate use-cases."
1360
1373
msgstr ""
1374
+ "``patch.dict(...)``、``patch.multiple(...)`` 和 ``patch.object(...)`` 可用於"
1375
+ "其餘的使用情境。"
1361
1376
1362
1377
#: ../../library/unittest.mock.rst:1415
1363
1378
msgid ""
1364
1379
":func:`patch` as function decorator, creating the mock for you and passing "
1365
1380
"it into the decorated function::"
1366
1381
msgstr ""
1382
+ ":func:`patch` 作為函式裝飾器,為你建立 mock 並將其傳遞給被裝飾的函式: ::"
1367
1383
1368
1384
#: ../../library/unittest.mock.rst:1425
1369
1385
msgid ""
1370
1386
"Patching a class replaces the class with a :class:`MagicMock` *instance*. If "
1371
1387
"the class is instantiated in the code under test then it will be the :attr:"
1372
1388
"`~Mock.return_value` of the mock that will be used."
1373
1389
msgstr ""
1390
+ "Patch 一個類別會以 :class:`MagicMock` *實例*取代該類別。 如果該類別在被測試的"
1391
+ "程式碼中實例化,那麼它將是會被使用的 mock 的:attr:`~Mock.return_value`。"
1374
1392
1375
1393
#: ../../library/unittest.mock.rst:1429
1376
1394
msgid ""
1377
1395
"If the class is instantiated multiple times you could use :attr:`~Mock."
1378
1396
"side_effect` to return a new mock each time. Alternatively you can set the "
1379
1397
"*return_value* to be anything you want."
1380
1398
msgstr ""
1399
+ "如果該類別被實例化多次,你可以使用:attr:`~Mock.side_effect` 來每次回傳一個新"
1400
+ "的 mock。 或者你可以將 *return_value* 設定成你想要的任何值。"
1381
1401
1382
1402
#: ../../library/unittest.mock.rst:1433
1383
1403
msgid ""
1384
1404
"To configure return values on methods of *instances* on the patched class "
1385
1405
"you must do this on the :attr:`return_value`. For example::"
1386
1406
msgstr ""
1407
+ "若要配置被 patch 的類別的*實例*方法的回傳值,你必須在 :attr:`return_value`上"
1408
+ "進行配置。 例如: ::"
1387
1409
1388
1410
#: ../../library/unittest.mock.rst:1447
1389
1411
msgid ""