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

Appearance settings

Commit f47ed7f

Browse filesBrowse files
committed
feat: to rst:1122
1 parent c6f6b9f commit f47ed7f
Copy full SHA for f47ed7f

File tree

Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed

‎library/unittest.mock-examples.po

Copy file name to clipboardExpand all lines: library/unittest.mock-examples.po
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: Python 3.12\n"
99
"Report-Msgid-Bugs-To: \n"
1010
"POT-Creation-Date: 2023-09-09 00:03+0000\n"
11-
"PO-Revision-Date: 2024-03-26 20:46+0800\n"
11+
"PO-Revision-Date: 2024-03-28 22:08+0800\n"
1212
"Last-Translator: Liang-Bo Wang <me@liang2.tw>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -1084,6 +1084,8 @@ msgid ""
10841084
"There are various reasons why you might want to subclass :class:`Mock`. One "
10851085
"reason might be to add helper methods. Here's a silly example:"
10861086
msgstr ""
1087+
"你會想子類別化 :class:`Mock` 的原因可能有很多種。其中之一是增加輔助方法。以下"
1088+
"是一個有點笨的例子:"
10871089

10881090
#: ../../library/unittest.mock-examples.rst:1083
10891091
msgid ""
@@ -1094,6 +1096,10 @@ msgid ""
10941096
"methods then they'll also be available on the attributes and return value "
10951097
"mock of instances of your subclass."
10961098
msgstr ""
1099+
"``Mock`` 實例的標準行為是屬性 mock 和回傳值 mock 會與存取它們的 mock 具有相同"
1100+
"的型別。這確保了 ``Mock`` 屬性是 ``Mocks``,``MagicMock`` 屬性是 "
1101+
"``MagicMocks`` [#]_。因此,如果你要子類別化以新增輔助方法,那麼它們也可用於子"
1102+
"類別實例的屬性 mock 和回傳值 mock。"
10971103

10981104
#: ../../library/unittest.mock-examples.rst:1099
10991105
msgid ""
@@ -1102,6 +1108,10 @@ msgid ""
11021108
"adaptor <https://twisted.org/documents/11.0.0/api/twisted.python.components."
11031109
"html>`_. Having this applied to attributes too actually causes errors."
11041110
msgstr ""
1111+
"有時候這很不方便。例如,`有一個使用者 <https://code.google.com/archive/p/"
1112+
"mock/issues/105>`_\\ 正在子類別化 mock 以建立 `Twisted adaptor <https://"
1113+
"twisted.org/documents/11.0.0/api/twisted.python.components.html>`_。將其應用"
1114+
"於屬性實際上會導致錯誤。"
11051115

11061116
#: ../../library/unittest.mock-examples.rst:1105
11071117
msgid ""
@@ -1111,13 +1121,18 @@ msgid ""
11111121
"signature is that it takes arbitrary keyword arguments (``**kwargs``) which "
11121122
"are then passed onto the mock constructor:"
11131123
msgstr ""
1124+
"``Mock`` (及其各種形式)使用名為 ``_get_child_mock`` 的方法來為屬性和回傳值"
1125+
"建立這些 \"子 mock\"。你可以透過置換此方法來防止你的子類別被用為屬性。其簽名"
1126+
"是取用任意的關鍵字引數(``**kwargs``\\ ),然後將其傳遞給 mock 建構函式:"
11141127

11151128
#: ../../library/unittest.mock-examples.rst:1122
11161129
msgid ""
11171130
"An exception to this rule are the non-callable mocks. Attributes use the "
11181131
"callable variant because otherwise non-callable mocks couldn't have callable "
11191132
"methods."
11201133
msgstr ""
1134+
"此規則的例外是非可呼叫物件的 mock。屬性使用可呼叫物件的變體,否則非可呼叫物件"
1135+
"的 mock 無法具有可呼叫物件的方法。"
11211136

11221137
#: ../../library/unittest.mock-examples.rst:1128
11231138
msgid "Mocking imports with patch.dict"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.