Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate library/unittest.mock.po from rst:384 to 817 #662

Merged
merged 8 commits into from
Nov 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 60 additions & 25 deletions library/unittest.mock.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-22 00:04+0000\n"
"PO-Revision-Date: 2023-09-09 23:07+0800\n"
"PO-Revision-Date: 2023-09-27 00:27+0800\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
Expand Down Expand Up @@ -253,16 +253,16 @@ msgid ""
"class of :class:`Mock` using the *new_callable* argument to :func:`patch`."
msgstr ""
":func:`patch` 裝飾器可以輕鬆地用 :class:`Mock` 物件臨時替換特定模組中的類別。"
"預設情況下,:func:`patch` 會為你建立一個 :class:`MagicMock`。你可以使"
"用 :func:`patch` 的 *new_callable* 引數指定 :class:`Mock` 的替代類別。"
"預設情況下,:func:`patch` 會為你建立一個 :class:`MagicMock`。你可以使用 :"
"func:`patch` 的 *new_callable* 引數指定 :class:`Mock` 的替代類別。"

#: ../../library/unittest.mock.rst:231
msgid ""
"Create a new :class:`Mock` object. :class:`Mock` takes several optional "
"arguments that specify the behaviour of the Mock object:"
msgstr ""
"建立一個新的 :class:`Mock` 物件。:class:`Mock` 接受數個可選的引數來指定 "
"Mock 物件的行為:"
"建立一個新的 :class:`Mock` 物件。:class:`Mock` 接受數個可選的引數來指定 Mock "
"物件的行為:"

#: ../../library/unittest.mock.rst:234
msgid ""
Expand Down Expand Up @@ -428,8 +428,8 @@ msgid ""
"assert the mock has been called with the specified calls. The :attr:"
"`mock_calls` list is checked for the calls."
msgstr ""
"斷言 mock 已經使用指定的呼叫方式來呼叫。此斷言會檢查 :attr:`mock_calls` 串列中的"
"呼叫。"
"斷言 mock 已經使用指定的呼叫方式來呼叫。此斷言會檢查 :attr:`mock_calls` 串列"
"中的呼叫。"

#: ../../library/unittest.mock.rst:365
msgid ""
Expand All @@ -449,15 +449,15 @@ msgstr ""

#: ../../library/unittest.mock.rst:384
msgid "Assert the mock was never called."
msgstr ""
msgstr "斷言 mock 從未被呼叫。"

#: ../../library/unittest.mock.rst:399
msgid "The reset_mock method resets all the call attributes on a mock object:"
msgstr ""
msgstr "reset_mock 方法重置 mock 物件上的所有呼叫屬性:"

#: ../../library/unittest.mock.rst:409
msgid "Added two keyword-only arguments to the reset_mock function."
msgstr ""
msgstr "reset_mock 函式新增了兩個僅限關鍵字引數 (keyword-only arguments)。"

#: ../../library/unittest.mock.rst:412
msgid ""
Expand All @@ -468,101 +468,119 @@ msgid ""
"`side_effect`, then pass the corresponding parameter as ``True``. Child "
"mocks and the return value mock (if any) are reset as well."
msgstr ""
"這在你想要進行一系列重複使用同一物件的斷言時非常有用。請注意,預設情況下,:"
"meth:`reset_mock` *不會* 清除回傳值、:attr:`side_effect` 或使用普通賦值設定的"
ken71301 marked this conversation as resolved.
Show resolved Hide resolved
"任何子屬性。如果你想要重置 *return_value* 或 :attr:`side_effect`,則將相應的"
"參數設置為 ``True``。Child mock 和回傳值 mock(如果有的話)也會被重置。"

#: ../../library/unittest.mock.rst:420
msgid "*return_value*, and :attr:`side_effect` are keyword-only arguments."
msgstr ""
msgstr "*return_value* 和 :attr:`side_effect` 是僅限關鍵字引數。"
rockleona marked this conversation as resolved.
Show resolved Hide resolved

#: ../../library/unittest.mock.rst:426
msgid ""
"Add a spec to a mock. *spec* can either be an object or a list of strings. "
"Only attributes on the *spec* can be fetched as attributes from the mock."
msgstr ""
"向 mock 增加一個規格 (spec)。*spec* 可以是一個物件或一個字串串列 (list of "
"strings)。只有在 *spec* 上的屬性才能作為 mock 的屬性被取得。"

#: ../../library/unittest.mock.rst:430
msgid "If *spec_set* is true then only attributes on the spec can be set."
msgstr ""
msgstr "如果 *spec_set* 為 true,那麼只能設定在規格中的屬性。"

#: ../../library/unittest.mock.rst:435
msgid ""
"Attach a mock as an attribute of this one, replacing its name and parent. "
"Calls to the attached mock will be recorded in the :attr:`method_calls` and :"
"attr:`mock_calls` attributes of this one."
msgstr ""
"將一個 mock 作為這個 Mock 的屬性附加,取代它的名稱和上代 (parent)。對附加的 "
"mock 的呼叫將被記錄在這個 Mock 的 :attr:`method_calls` 和 :attr:`mock_calls` "
"屬性中。"
mattwang44 marked this conversation as resolved.
Show resolved Hide resolved

#: ../../library/unittest.mock.rst:442
msgid "Set attributes on the mock through keyword arguments."
msgstr ""
msgstr "透過關鍵字參數在 mock 上設定屬性。"
ken71301 marked this conversation as resolved.
Show resolved Hide resolved

#: ../../library/unittest.mock.rst:444
msgid ""
"Attributes plus return values and side effects can be set on child mocks "
"using standard dot notation and unpacking a dictionary in the method call:"
msgstr ""
"可以使用標準點記法 (dot notation) 並在使用 method(方法)呼叫時將字典拆開,"
ken71301 marked this conversation as resolved.
Show resolved Hide resolved
"為 child mock 設定屬性、回傳值和 side effects:"

#: ../../library/unittest.mock.rst:458
msgid "The same thing can be achieved in the constructor call to mocks:"
msgstr ""
msgstr "同樣的事情可以在 mock 的建構函式呼叫中實現:"

#: ../../library/unittest.mock.rst:471
msgid ""
":meth:`configure_mock` exists to make it easier to do configuration after "
"the mock has been created."
msgstr ""
":meth:`configure_mock` 的存在是為了在 mock 被建立後更容易進行組態設定。"

#: ../../library/unittest.mock.rst:477
msgid ""
":class:`Mock` objects limit the results of ``dir(some_mock)`` to useful "
"results. For mocks with a *spec* this includes all the permitted attributes "
"for the mock."
msgstr ""
":class:`Mock` 物件限制了 ``dir(some_mock)`` 僅顯示有用的結果。對於具有 "
"*spec* 的 mock,這包含所有被允許的 mock 屬性。"

#: ../../library/unittest.mock.rst:481
msgid ""
"See :data:`FILTER_DIR` for what this filtering does, and how to switch it "
"off."
msgstr ""
msgstr "請參閱 :data:`FILTER_DIR` 以了解這種過濾行為的作用,以及如何關閉它。"

#: ../../library/unittest.mock.rst:487
msgid ""
"Create the child mocks for attributes and return value. By default child "
"mocks will be the same type as the parent. Subclasses of Mock may want to "
"override this to customize the way child mocks are made."
msgstr ""
"建立為了得到屬性和回傳值的 child mock。預設情況下,child mock 將與其上代是相"
"同的類型。Mock 的子類別可能會想要置換此行為,以自定義 child mock 的建立方式。"
ken71301 marked this conversation as resolved.
Show resolved Hide resolved

#: ../../library/unittest.mock.rst:492
msgid ""
"For non-callable mocks the callable variant will be used (rather than any "
"custom subclass)."
msgstr ""
msgstr "對於不可呼叫的 mock,將使用可呼叫的變體,而不是任何的自定義子類別。"

#: ../../library/unittest.mock.rst:498
msgid "A boolean representing whether or not the mock object has been called:"
msgstr ""
msgstr "一個 boolean(布林),表述 mock 物件是否已經被呼叫:"

#: ../../library/unittest.mock.rst:509
msgid "An integer telling you how many times the mock object has been called:"
msgstr ""
msgstr "一個整數,告訴你 mock 物件被呼叫的次數:"

#: ../../library/unittest.mock.rst:521
msgid "Set this to configure the value returned by calling the mock:"
msgstr ""
msgstr "設定此值以配置呼叫 mock 時回傳的值:"

#: ../../library/unittest.mock.rst:528
msgid ""
"The default return value is a mock object and you can configure it in the "
"normal way:"
msgstr ""
msgstr "預設的回傳值是一個 mock 物件,你也可以按照正常的方式配置它:"

#: ../../library/unittest.mock.rst:537
msgid ":attr:`return_value` can also be set in the constructor:"
msgstr ""
msgstr ":attr:`return_value` 也可以在建構函式中設定:"

#: ../../library/unittest.mock.rst:548
msgid ""
"This can either be a function to be called when the mock is called, an "
"iterable or an exception (class or instance) to be raised."
msgstr ""
"這可以是一個在呼叫 mock 時要呼叫的函式、一個可疊代物件,或者要引發的例外(類"
"別或實例)。"

#: ../../library/unittest.mock.rst:551
msgid ""
Expand All @@ -572,6 +590,10 @@ msgid ""
"returns :data:`DEFAULT` then the mock will return its normal value (from "
"the :attr:`return_value`)."
msgstr ""
"如果你傳遞一個函式,它將被呼叫,其引數與 mock 相同,且除非該函式回傳 :data:"
"`DEFAULT` 單例 (singleton),否則對 mock 的呼叫將回傳函式回傳的任何值。如果函"
"式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值(從 :attr:"
"`return_value` 得到)。"

#: ../../library/unittest.mock.rst:557
msgid ""
Expand All @@ -580,30 +602,35 @@ msgid ""
"to be raised, or a value to be returned from the call to the mock (:data:"
"`DEFAULT` handling is identical to the function case)."
msgstr ""
"如果你傳遞一個可疊代物件,它將被用於檢索一個疊代器,該疊代器必須在每次呼叫時"
"產出 (yield) 一個值。這個值可以是要引發的例外實例,或者是對 mock 呼叫時要回傳"
"的值(處理 :data:`DEFAULT` 的方式與函式的狀況相同)。"

#: ../../library/unittest.mock.rst:562
msgid ""
"An example of a mock that raises an exception (to test exception handling of "
"an API):"
msgstr ""
msgstr "以下是一個引發例外的 mock 的範例(用於測試 API 的例外處理):"

#: ../../library/unittest.mock.rst:572
msgid "Using :attr:`side_effect` to return a sequence of values:"
msgstr ""
msgstr "使用 :attr:`side_effect` 回傳一連串值的範例:"

#: ../../library/unittest.mock.rst:579
msgid "Using a callable:"
msgstr ""
msgstr "使用可被呼叫物件的範例:"

#: ../../library/unittest.mock.rst:589
msgid ""
":attr:`side_effect` can be set in the constructor. Here's an example that "
"adds one to the value the mock is called with and returns it:"
msgstr ""
":attr:`side_effect` 可以在建構函式中設定。以下是一個範例,它將 mock 被呼叫時"
"給的值加一並回傳:"

#: ../../library/unittest.mock.rst:599
msgid "Setting :attr:`side_effect` to ``None`` clears it:"
msgstr ""
msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:"

#: ../../library/unittest.mock.rst:613
msgid ""
Expand All @@ -614,6 +641,10 @@ msgid ""
"second member, which can also be accessed through the ``kwargs`` property, "
"is any keyword arguments (or an empty dictionary)."
msgstr ""
"這會是 ``None``(如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引數。這"
"將以元組的形式呈現:第一個構件 (member),其可以通過 ``args`` 屬性訪問,是 "
rockleona marked this conversation as resolved.
Show resolved Hide resolved
"mock 被呼叫時傳遞的所有有序引數(或一個空元組)。第二個構件,其可以通過 "
"``kwargs`` 屬性訪問,是所有關鍵字引數(或一個空字典)。"

#: ../../library/unittest.mock.rst:646
msgid ""
Expand All @@ -622,6 +653,10 @@ msgid ""
"are tuples, so they can be unpacked to get at the individual arguments and "
"make more complex assertions. See :ref:`calls as tuples <calls-as-tuples>`."
msgstr ""
":attr:`call_args`,以及串列 :attr:`call_args_list`、:attr:`method_calls` 和 :"
"attr:`mock_calls` 的構件都是 :data:`call` 物件。這些都是元組,因此可以解包以"
"獲取各個引數並進行更複雜的斷言。參見 :ref:`calls as tuples <calls-as-"
"tuples>`。"

#: ../../library/unittest.mock.rst:652
msgid "Added ``args`` and ``kwargs`` properties."
Expand Down