@@ -8,7 +8,7 @@ msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2023-07-22 00:04+0000\n "
11
- "PO-Revision-Date : 2023-08-22 21:58 +0800\n "
11
+ "PO-Revision-Date : 2023-08-22 22:20 +0800\n "
12
12
"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -33,8 +33,8 @@ msgid ""
33
33
"replace parts of your system under test with mock objects and make "
34
34
"assertions about how they have been used."
35
35
msgstr ""
36
- ":mod:`unittest.mock`\\ 在 Python 中是一個用於進行測試的函式庫。 它允許你用模 "
37
- "擬物件 (mock object) 在測試中替換部分系統,並判定它們是如何被使用的。"
36
+ ":mod:`unittest.mock` 在 Python 中是一個用於進行測試的函式庫。 它允許你用模擬 "
37
+ "物件 (mock object) 在測試中替換部分系統,並判定它們是如何被使用的。"
38
38
39
39
#: ../../library/unittest.mock.rst:21
40
40
msgid ""
@@ -44,10 +44,9 @@ msgid ""
44
44
"and arguments they were called with. You can also specify return values and "
45
45
"set needed attributes in the normal way."
46
46
msgstr ""
47
- ":mod:`unittest.mock`\\ 提供了一個以\\ :class:`Mock`\\ 為核心的類別,去除在測"
48
- "試中建立大量 stubs 的需求。 在執行動作之後,你可以判定哪些 method (方法)/"
49
- "屬性被使用,以及有哪些引數被呼叫。 你還可以用常規的方式指定回傳值與設定所需的"
50
- "屬性。"
47
+ ":mod:`unittest.mock` 提供了一個以 :class:`Mock` 為核心的類別,去除在測試中建"
48
+ "立大量 stubs 的需求。 在執行動作之後,你可以判定哪些 method (方法)/屬性被"
49
+ "使用,以及有哪些引數被呼叫。 你還可以用常規的方式指定回傳值與設定所需的屬性。"
51
50
52
51
#: ../../library/unittest.mock.rst:27
53
52
msgid ""
@@ -57,18 +56,18 @@ msgid ""
57
56
"some examples of how to use :class:`Mock`, :class:`MagicMock` and :func:"
58
57
"`patch`."
59
58
msgstr ""
60
- "此外,mock 還提供了一個\\ :func:`patch`\\ 裝飾器,用於 patching 測試範圍內對 "
61
- "module(模組)以及 class(類別)級別的屬性,以及用於建立唯一物件的\\ :const:"
62
- "`sentinel`\\ 。有關如何使用\\ :class:`Mock`\\ 、\\ :class:`MagicMock`\\ 和 \\ :"
63
- "func: `patch`\\ 的一些範例,請參閱\\ `快速導引 <quick guide_>`_。"
59
+ "此外,mock 還提供了一個 :func:`patch` 裝飾器,用於 patching 測試範圍內對 "
60
+ "module(模組)以及 class(類別)級別的屬性,以及用於建立唯一物件的 :const:"
61
+ "`sentinel`\\ 。有關如何使用 :class:`Mock`\\ 、\\ :class:`MagicMock` 和 :func :"
62
+ "`patch` 的一些範例,請參閱\\ `快速導引 <quick guide_>`_。"
64
63
65
64
#: ../../library/unittest.mock.rst:33
66
65
msgid ""
67
66
"Mock is designed for use with :mod:`unittest` and is based on the 'action -> "
68
67
"assertion' pattern instead of 'record -> replay' used by many mocking "
69
68
"frameworks."
70
69
msgstr ""
71
- "Mock 被設計用於與\\ :mod:`unittest`\\ 一起使用,並且基於 「action(操作) -> "
70
+ "Mock 被設計用於與 :mod:`unittest` 一起使用,並且基於 「action(操作) -> "
72
71
"assertion(判定)」 模式,而不是許多模擬框架使用的 「record(記錄) -> replay"
73
72
"(重播)」 模式。"
74
73
@@ -77,8 +76,8 @@ msgid ""
77
76
"There is a backport of :mod:`unittest.mock` for earlier versions of Python, "
78
77
"available as `mock on PyPI <https://pypi.org/project/mock>`_."
79
78
msgstr ""
80
- "對於早期版本的 Python,有一個 backport(向後移植的)\\ :mod:`unittest."
81
- "mock` \\ 可以使用,\\ `從 PyPI 下載 mock <https://pypi.org/project/mock>`_。"
79
+ "對於早期版本的 Python,有一個 backport(向後移植的)\\ :mod:`unittest.mock` "
80
+ "可以使用,\\ `從 PyPI 下載 mock <https://pypi.org/project/mock>`_。"
82
81
83
82
#: ../../library/unittest.mock.rst:42
84
83
msgid "Quick Guide"
@@ -91,16 +90,16 @@ msgid ""
91
90
"can configure them, to specify return values or limit what attributes are "
92
91
"available, and then make assertions about how they have been used:"
93
92
msgstr ""
94
- ":class:`Mock`\\ 和 \\ :class:`MagicMock`\\ 物件在你存取它們時建立所有屬性和 "
95
- "method (方法),並儲存它們如何被使用的詳細訊息。你可以配置它們,以指定回傳值 "
96
- "或限制可用的屬性 ,然後對它們的使用方式做出判定:"
93
+ ":class:`Mock` 和 :class:`MagicMock` 物件在你存取它們時建立所有屬性和 method "
94
+ "(方法),並儲存它們如何被使用的詳細訊息。你可以配置它們,以指定回傳值或限制 "
95
+ "可用的屬性 ,然後對它們的使用方式做出判定:"
97
96
98
97
#: ../../library/unittest.mock.rst:72
99
98
msgid ""
100
99
":attr:`side_effect` allows you to perform side effects, including raising an "
101
100
"exception when a mock is called:"
102
101
msgstr ""
103
- ":attr:`side_effect`\\ 允許你執行 side effects,包含在 mock 被呼叫時引發例外:"
102
+ ":attr:`side_effect` 允許你執行 side effects,包含在 mock 被呼叫時引發例外:"
104
103
105
104
#: ../../library/unittest.mock.rst:93
106
105
msgid ""
@@ -109,9 +108,9 @@ msgid ""
109
108
"from another object. Attempting to access attributes or methods on the mock "
110
109
"that don't exist on the spec will fail with an :exc:`AttributeError`."
111
110
msgstr ""
112
- "Mock 有許多其他方法可以讓你配置與控制它的行為。例如,\\ *spec*\\ 引數可以配 "
113
- "置 mock ,讓其從另一個物件獲取規格。嘗試讀取 mock 中不存在於規格中的屬性或方 "
114
- "法將會失敗 ,並出現\\ :exc:`AttributeError`\\ 。"
111
+ "Mock 有許多其他方法可以讓你配置與控制它的行為。例如,\\ *spec* 引數可以配置 "
112
+ "mock ,讓其從另一個物件獲取規格。嘗試讀取 mock 中不存在於規格中的屬性或方法將 "
113
+ "會失敗 ,並出現 :exc:`AttributeError`\\ 。"
115
114
116
115
#: ../../library/unittest.mock.rst:98
117
116
msgid ""
@@ -120,8 +119,8 @@ msgid ""
120
119
"with a mock (or other object) during the test and restored when the test "
121
120
"ends::"
122
121
msgstr ""
123
- ":func:`patch`\\ 裝飾器 / 情境管理器可以在測試中簡單的模擬模組中的類別或物件。"
124
- "被指定的物件在測試期間會被替換為 mock(或其他物件),並在測試結束時恢復:\n"
122
+ ":func:`patch` 裝飾器/ 情境管理器可以在測試中簡單的模擬模組中的類別或物件。被 "
123
+ "指定的物件在測試期間會被替換為 mock(或其他物件),並在測試結束時恢復:\n"
125
124
"\n"
126
125
"::"
127
126
@@ -133,33 +132,33 @@ msgid ""
133
132
"above the mock for ``module.ClassName1`` is passed in first."
134
133
msgstr ""
135
134
"當你嵌套 patch 裝飾器時,mock 會以被應用的順序傳遞到裝飾函數(裝飾器應用的正"
136
- "常\\ *Python*\\ 順序)。這意味著由下而上,因此在上面的範例中,\\ ``module."
137
- "ClassName1``\\ 的 mock 會先被傳入。"
135
+ "常 *Python* 順序)。這意味著由下而上,因此在上面的範例中,\\ ``module."
136
+ "ClassName1`` 的 mock 會先被傳入。"
138
137
139
138
#: ../../library/unittest.mock.rst:122
140
139
msgid ""
141
140
"With :func:`patch` it matters that you patch objects in the namespace where "
142
141
"they are looked up. This is normally straightforward, but for a quick guide "
143
142
"read :ref:`where to patch <where-to-patch>`."
144
143
msgstr ""
145
- "使用\\ :func:`patch`\\ 時,需注意的是你得在被查找物件的命名空間中(in the "
144
+ "使用 :func:`patch` 時,需注意的是你得在被查找物件的命名空間中(in the "
146
145
"namespace where they are looked up)patch 物件。這通常很直接,但若需要快速導"
147
146
"引,請參閱\\ :ref:`該 patch 何處 <where-to-patch>`\\ 。"
148
147
149
148
#: ../../library/unittest.mock.rst:126
150
149
msgid ""
151
150
"As well as a decorator :func:`patch` can be used as a context manager in a "
152
151
"with statement:"
153
- msgstr "裝飾器\\ :func:`patch`\\ 也可以在 with 陳述式中被用來作為情境管理器:"
152
+ msgstr "裝飾器 :func:`patch` 也可以在 with 陳述式中被用來作為情境管理器:"
154
153
155
154
#: ../../library/unittest.mock.rst:136
156
155
msgid ""
157
156
"There is also :func:`patch.dict` for setting values in a dictionary just "
158
157
"during a scope and restoring the dictionary to its original state when the "
159
158
"test ends:"
160
159
msgstr ""
161
- "也有\\ :func:`patch.dict`\\ ,用於在測試範圍中設定 dictionary(字典)內的值,"
162
- "並在測試結束時將其恢復為原始狀態 :"
160
+ "也有 :func:`patch.dict`\\ ,用於在測試範圍中設定 dictionary(字典)內的值,並 "
161
+ "在測試結束時將其恢復為原始狀態 :"
163
162
164
163
#: ../../library/unittest.mock.rst:147
165
164
msgid ""
@@ -168,7 +167,7 @@ msgid ""
168
167
"It allows you to do things like:"
169
168
msgstr ""
170
169
"Mock 支援對 Python的\\ :ref:`魔術方法 <magic-methods>`\\ 的模擬。最簡單使用魔"
171
- "術方法的方式是使用\\ :class:`MagicMock`\\ 類別。它允許你執行以下操作:"
170
+ "術方法的方式是使用 :class:`MagicMock` 類別。它允許你執行以下操作:"
172
171
173
172
#: ../../library/unittest.mock.rst:157
174
173
msgid ""
@@ -178,8 +177,8 @@ msgid ""
178
177
"(well, all the useful ones anyway)."
179
178
msgstr ""
180
179
"Mock 允許你將函式(或其他 Mock 實例)分配給魔術方法,並且它們將被適當地呼"
181
- "叫。\\ :class:`MagicMock`\\ 類別是一個 Mock 的變體,它為你預先建好了所有魔術 "
182
- "方法 (好吧,所有有用的方法)。"
180
+ "叫。\\ :class:`MagicMock` 類別是一個 Mock 的變體,它為你預先建好了所有魔術方 "
181
+ "法 (好吧,所有有用的方法)。"
183
182
184
183
#: ../../library/unittest.mock.rst:162
185
184
msgid ""
@@ -198,10 +197,10 @@ msgid ""
198
197
"same call signature as the real object."
199
198
msgstr ""
200
199
"為了確保測試中的模擬物件與它們要替換的物件具有相同的 api,你可以使用\\ :ref:`"
201
- "自動規格 <auto-speccing>`\\ 。自動規格(auto-speccing)可以通過 patch 的\\ "
202
- "*autospec*\\ 引數或\\ :func:`create_autospec`\\ 函式來完成。自動規格創建的模 "
203
- "擬物件與它們要替換的對象具有相同的屬性和方法 ,並且任何函式和方法(包括建構函 "
204
- "式)都具有與真實物件相同的調用簽名 (call signature)。"
200
+ "自動規格 <auto-speccing>`\\ 。自動規格(auto-speccing)可以通過 patch 的 "
201
+ "*autospec* 引數或 :func:`create_autospec` 函式來完成。自動規格創建的模擬物件 "
202
+ "與它們要替換的對象具有相同的屬性和方法 ,並且任何函式和方法(包括建構函式)都 "
203
+ "具有與真實物件相同的調用簽名 (call signature)。"
205
204
206
205
#: ../../library/unittest.mock.rst:178
207
206
msgid ""
@@ -215,8 +214,8 @@ msgid ""
215
214
"signature of the ``__init__`` method, and on callable objects where it "
216
215
"copies the signature of the ``__call__`` method."
217
216
msgstr ""
218
- ":func:`create_autospec`\\ 也可以用在類別上,它複製了\\ ``__init__``\\ 方法的 "
219
- "簽名, 它也可以用在可調用物件上,其複製了\\ ``__call__``\\ 方法的簽名。"
217
+ ":func:`create_autospec` 也可以用在類別上,它複製了 ``__init__`` 方法的簽名, "
218
+ "它也可以用在可調用物件上,其複製了 ``__call__`` 方法的簽名。"
220
219
221
220
#: ../../library/unittest.mock.rst:201
222
221
msgid "The Mock Class"
0 commit comments