@@ -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-0901 :08+0800\n "
10+ "PO-Revision-Date :2024-01-0923 :08+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 "
@@ -1235,6 +1235,10 @@ msgid ""
12351235"If :func:`patch` is used as a context manager the created mock is returned "
12361236"by the context manager."
12371237msgstr ""
1238+ "如果 *new* 被省略,則如果被 patch 的物件是非同步函式,目標會被替換為 :class:"
1239+ "`AsyncMock`,反之則替換為 :class:`MagicMock`。如果 :func:`patch` 做為裝飾器使"
1240+ "用且省略了 *new*,則所建立的 mock 會作為額外的引數傳遞給被裝飾的函式。如果 :"
1241+ "func:`patch` 作為情境管理器使用,則所建立的 mock 將由情境管理器回傳。"
12381242
12391243#: ../../library/unittest.mock.rst:1353
12401244msgid ""
@@ -1244,25 +1248,36 @@ msgid ""
12441248"calling :func:`patch` from. The target is imported when the decorated "
12451249"function is executed, not at decoration time."
12461250msgstr ""
1251+ "*target* 應該是以 ``'package.module.ClassName'`` 形式出現的字串。*target* 會"
1252+ "被引入並用 *new* 物件替換指定的物件,因此 *target* 必須可從你呼叫 :func:"
1253+ "`patch` 的環境中引入。target 在執行被裝飾的函式時被引入,而不是在裝飾器作用"
1254+ "時 (decoration time)。"
12471255
12481256#: ../../library/unittest.mock.rst:1359
12491257msgid ""
12501258"The *spec* and *spec_set* keyword arguments are passed to the :class:"
12511259"`MagicMock` if patch is creating one for you."
12521260msgstr ""
1261+ "*spec* 和 *spec_set* 關鍵字引數會傳遞給 :class:`MagicMock`,如果 patch 正在為"
1262+ "你建立一個。"
12531263
12541264#: ../../library/unittest.mock.rst:1362
12551265msgid ""
12561266"In addition you can pass ``spec=True`` or ``spec_set=True``, which causes "
12571267"patch to pass in the object being mocked as the spec/spec_set object."
12581268msgstr ""
1269+ "此外,你還可以傳遞 ``spec=True``或 ``spec_set=True``,這將導致 patch 將被 "
1270+ "mock 的物件作為 spec/spec_set 物件傳遞。"
12591271
12601272#: ../../library/unittest.mock.rst:1365
12611273msgid ""
12621274"*new_callable* allows you to specify a different class, or callable object, "
12631275"that will be called to create the *new* object. By default :class:"
12641276"`AsyncMock` is used for async functions and :class:`MagicMock` for the rest."
12651277msgstr ""
1278+ "*new_callable* 允許你指定一個不同的類別或可呼叫的物件,用於被呼叫並建立 "
1279+ "*new* 物件。預設情況下,對於非同步函式使用 :class:`AsyncMock`,而對於其他情況"
1280+ "則使用 :class:`MagicMock`。"
12661281
12671282#: ../../library/unittest.mock.rst:1369
12681283msgid ""
@@ -1275,12 +1290,20 @@ msgid ""
12751290"return value (the 'instance') will have the same spec as the class. See the :"
12761291"func:`create_autospec` function and :ref:`auto-speccing`."
12771292msgstr ""
1293+ "*spec* 的一種更強大的形式是 *autospec*。如果你設定 ``autospec=True``,則該 "
1294+ "mock 將使用被替換物件的規格來建立。該 mock 的所有屬性也將具有被替換物件的對應"
1295+ "屬性的規格。被 mock 的方法和函式將檢查其引數,如果呼叫時引數與規格不符(被使"
1296+ "用錯誤的簽名 (signature) 呼叫),將引發 :exc:`TypeError`。對於替換類別的 "
1297+ "mock,它們的回傳值(即 'instance')將具有與類別相同的規格。請參閱 :func:"
1298+ "`create_autospec` 函式和 :ref:`auto-speccing`。"
12781299
12791300#: ../../library/unittest.mock.rst:1379
12801301msgid ""
12811302"Instead of ``autospec=True`` you can pass ``autospec=some_object`` to use an "
12821303"arbitrary object as the spec instead of the one being replaced."
12831304msgstr ""
1305+ "你可以用 ``autospec=some_object`` 替代 ``autospec=True``,以使用任意物件作為"
1306+ "規格,而不是被替換的物件。"
12841307
12851308#: ../../library/unittest.mock.rst:1382
12861309msgid ""
@@ -1292,6 +1315,11 @@ msgid ""
12921315"off by default because it can be dangerous. With it switched on you can "
12931316"write passing tests against APIs that don't actually exist!"
12941317msgstr ""
1318+ "預設情況下,:func:`patch` 將無法取代不存在的屬性。如果你傳入 "
1319+ "``create=True``,且屬性不存在,則當被 patch 的函式被呼叫時,patch 將為你建立"
1320+ "該屬性,並在被 patch 的函式結束後再次刪除它。這對於撰寫針對你的生產程式碼在執"
1321+ "行環境建立的屬性的測試時非常有用。此功能預設為關閉,因為這可能會相當危險。開"
1322+ "啟這個功能後,你可以對於實際上不存在的 API 撰寫會通過的測試!"
12951323
12961324#: ../../library/unittest.mock.rst:1392
12971325msgid ""