From 8fef8f1296eca7783242a63df7ea08988c3da955 Mon Sep 17 00:00:00 2001 From: Payon Date: Mon, 4 Dec 2023 21:55:57 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=BF=BB=E8=AD=AF=20unittest.mock=20rs?= =?UTF-8?q?t:823=E8=87=B3rst:1103=20(#735)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Wei-Hsiang (Matt) Wang --- library/unittest.mock.po | 55 ++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/library/unittest.mock.po b/library/unittest.mock.po index 5afcfd1b40..2001f0e458 100644 --- a/library/unittest.mock.po +++ b/library/unittest.mock.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2023-10-20 00:03+0000\n" -"PO-Revision-Date: 2023-11-23 21:46+0800\n" +"PO-Revision-Date: 2023-12-04 21:31+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -827,12 +827,16 @@ msgid "" "class:`PropertyMock` provides :meth:`__get__` and :meth:`__set__` methods so " "you can specify a return value when it is fetched." msgstr "" +"一個理應在類別上當成屬性或其他描述器的 mock。:class:`PropertyMock` 提供了 :" +"meth:`__get__` 和 :meth:`__set__` 方法,因此你可以在它被提取時指定回傳值。" #: ../../library/unittest.mock.rst:827 msgid "" "Fetching a :class:`PropertyMock` instance from an object calls the mock, " "with no args. Setting it calls the mock with the value being set. ::" msgstr "" +"從物件中提取 :class:`PropertyMock` 實例會不帶任何引數呼叫 mock。設定它則會用" +"設定的值來呼叫 mock: ::" #: ../../library/unittest.mock.rst:848 msgid "" @@ -840,6 +844,8 @@ msgid "" "class:`PropertyMock` to a mock object. Instead you can attach it to the mock " "type object::" msgstr "" +"由於 mock 屬性的儲存方式,你無法直接將 :class:`PropertyMock` 附加到 mock 物" +"件。但是你可以將其附加到 mock 型別的物件: ::" #: ../../library/unittest.mock.rst:862 msgid "" @@ -847,24 +853,28 @@ msgid "" "will behave so the object is recognized as an async function, and the result " "of a call is an awaitable." msgstr "" +":class:`MagicMock` 的非同步版本。:class:`AsyncMock` 物件的表現將被視為非同步" +"函式,並且呼叫的結果是一個可等待物件。" #: ../../library/unittest.mock.rst:872 msgid "" "The result of ``mock()`` is an async function which will have the outcome of " "``side_effect`` or ``return_value`` after it has been awaited:" msgstr "" +"``mock()`` 的結果是一個非同步函式,在它被等待後將具有 ``side_effect`` 或 " +"``return_value`` 的結果:" #: ../../library/unittest.mock.rst:875 msgid "" "if ``side_effect`` is a function, the async function will return the result " "of that function," -msgstr "" +msgstr "如果 ``side_effect`` 是一個函式,非同步函式將回傳該函式的結果," #: ../../library/unittest.mock.rst:877 msgid "" "if ``side_effect`` is an exception, the async function will raise the " "exception," -msgstr "" +msgstr "如果 ``side_effect`` 是一個例外,則非同步函式將引發該例外," #: ../../library/unittest.mock.rst:879 msgid "" @@ -872,6 +882,8 @@ msgid "" "value of the iterable, however, if the sequence of result is exhausted, " "``StopAsyncIteration`` is raised immediately," msgstr "" +"如果 ``side_effect`` 是一個可疊代物件,非同步函式將回傳可疊代物件的下一個值," +"但如果結果序列耗盡,將立即引發 ``StopAsyncIteration``," #: ../../library/unittest.mock.rst:882 msgid "" @@ -879,12 +891,16 @@ msgid "" "defined by ``return_value``, hence, by default, the async function returns a " "new :class:`AsyncMock` object." msgstr "" +"如果 ``side_effect`` 沒有被定義,非同步函式將回傳由 ``return_value`` 定義的" +"值,因此在預設情況下,非同步函式回傳一個新的 :class:`AsyncMock` 物件。" #: ../../library/unittest.mock.rst:887 msgid "" "Setting the *spec* of a :class:`Mock` or :class:`MagicMock` to an async " "function will result in a coroutine object being returned after calling." msgstr "" +"將 :class:`Mock` 或 :class:`MagicMock` 的 *spec* 設定為非同步函式將導致在呼叫" +"後回傳一個協程物件。" #: ../../library/unittest.mock.rst:899 msgid "" @@ -895,63 +911,78 @@ msgid "" "or :class:`Mock` (if the parent mock is :class:`Mock`). All asynchronous " "functions will be :class:`AsyncMock`." msgstr "" +"將 :class:`Mock`、:class:`MagicMock` 或 :class:`AsyncMock` 的 *spec* 設定為具" +"有同步和非同步函式的類別,會自動檢測同步函式並將其設定為 :class:" +"`MagicMock`\\ (如果上代 mock 為 :class:`AsyncMock` 或 :class:" +"`MagicMock`\\ )或 :class:`Mock`\\ (如果上代 mock 為 :class:`Mock`\\ )。所" +"有非同步函式將被設定為 :class:`AsyncMock`。" #: ../../library/unittest.mock.rst:927 msgid "" "Assert that the mock was awaited at least once. Note that this is separate " "from the object having been called, the ``await`` keyword must be used:" msgstr "" +"斷言 mock 至少被等待過一次。請注意這與物件是否被呼叫是分開的,``await`` 關鍵" +"字必須被使用:" #: ../../library/unittest.mock.rst:946 msgid "Assert that the mock was awaited exactly once." -msgstr "" +msgstr "斷言 mock 正好被等待了一次。" #: ../../library/unittest.mock.rst:962 msgid "Assert that the last await was with the specified arguments." -msgstr "" +msgstr "斷言最後一次等待使用了指定的引數。" #: ../../library/unittest.mock.rst:979 msgid "" "Assert that the mock was awaited exactly once and with the specified " "arguments." -msgstr "" +msgstr "斷言 mock 只被等待了一次並使用了指定的引數。" #: ../../library/unittest.mock.rst:996 msgid "Assert the mock has ever been awaited with the specified arguments." -msgstr "" +msgstr "斷言 mock 曾經被使用指定的引數等待過。" #: ../../library/unittest.mock.rst:1012 msgid "" "Assert the mock has been awaited with the specified calls. The :attr:" "`await_args_list` list is checked for the awaits." msgstr "" +"斷言 mock 已被使用指定的呼叫進行等待。:attr:`await_args_list` 串列將被檢查以" +"確認等待的內容。" #: ../../library/unittest.mock.rst:1015 msgid "" "If *any_order* is false then the awaits must be sequential. There can be " "extra calls before or after the specified awaits." msgstr "" +"如果 *any_order* 為 false,則等待必須按照順序。指定的等待之前或之後可以有額外" +"的呼叫。" #: ../../library/unittest.mock.rst:1019 msgid "" "If *any_order* is true then the awaits can be in any order, but they must " "all appear in :attr:`await_args_list`." msgstr "" +"如果 *any_order* 為 true,則等待可以以任何順序出現,但它們必須全部出現在 :" +"attr:`await_args_list` 中。" #: ../../library/unittest.mock.rst:1039 msgid "Assert that the mock was never awaited." -msgstr "" +msgstr "斷言 mock 從未被等待。" #: ../../library/unittest.mock.rst:1046 msgid "" "See :func:`Mock.reset_mock`. Also sets :attr:`await_count` to 0, :attr:" "`await_args` to None, and clears the :attr:`await_args_list`." msgstr "" +"參見 :func:`Mock.reset_mock`。同時將 :attr:`await_count` 設定為 0,:attr:" +"`await_args` 設定為 None,並清除 :attr:`await_args_list`。" #: ../../library/unittest.mock.rst:1051 msgid "" "An integer keeping track of how many times the mock object has been awaited." -msgstr "" +msgstr "一個整數,用來記錄 mock 物件已被等待的次數。" #: ../../library/unittest.mock.rst:1066 msgid "" @@ -959,6 +990,8 @@ msgid "" "that the mock was last awaited with. Functions the same as :attr:`Mock." "call_args`." msgstr "" +"這可能是 ``None``\\ (如果 mock 尚未被等待),或者是上次等待 mock 時使用的引" +"數。與 :attr:`Mock.call_args` 的功能相同。" #: ../../library/unittest.mock.rst:1084 msgid "" @@ -966,10 +999,12 @@ msgid "" "length of the list is the number of times it has been awaited). Before any " "awaits have been made it is an empty list." msgstr "" +"這是一個按照順序記錄 mock 物件所有等待的串列(因此串列的長度表示該物件已被等" +"待的次數)。在進行任何等待之前,此串列為空。" #: ../../library/unittest.mock.rst:1103 msgid "Calling" -msgstr "" +msgstr "呼叫" #: ../../library/unittest.mock.rst:1105 msgid ""