Skip to content

Commit 6f3a72f

Browse files
committed
feat: to rst:228
1 parent cbb7556 commit 6f3a72f

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

library/unittest.mock-examples.po

Lines changed: 33 additions & 11 deletions
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: 2023-11-21 22:16+0800\n"
11+
"PO-Revision-Date: 2024-01-14 01:14+0800\n"
1212
"Last-Translator: Liang-Bo Wang <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -17,7 +17,7 @@ msgstr ""
1717
"Content-Type: text/plain; charset=UTF-8\n"
1818
"Content-Transfer-Encoding: 8bit\n"
1919
"Plural-Forms: nplurals=1; plural=0;\n"
20-
"X-Generator: Poedit 3.4\n"
20+
"X-Generator: Poedit 3.4.1\n"
2121

2222
#: ../../library/unittest.mock-examples.rst:2
2323
msgid ":mod:`unittest.mock` --- getting started"
@@ -131,7 +131,7 @@ msgstr ""
131131

132132
#: ../../library/unittest.mock-examples.rst:106
133133
msgid "Mocking Classes"
134-
msgstr ""
134+
msgstr "Mock 類別"
135135

136136
#: ../../library/unittest.mock-examples.rst:108
137137
msgid ""
@@ -140,6 +140,9 @@ msgid ""
140140
"Instances are created by *calling the class*. This means you access the "
141141
"\"mock instance\" by looking at the return value of the mocked class."
142142
msgstr ""
143+
"一個常見的例子是 mock 被測試的程式碼實例化的類別。 當你 patch 一個類別時,該"
144+
"類別就會被替換為 mock。 實例是透過*呼叫類別*建立的。 這代表你可以透過查看被 "
145+
"mock 的類別的回傳值來存取「mock 實例」。"
143146

144147
#: ../../library/unittest.mock-examples.rst:113
145148
msgid ""
@@ -149,28 +152,36 @@ msgid ""
149152
"mock, so it is configured by modifying the mock :attr:`~Mock."
150153
"return_value`. ::"
151154
msgstr ""
155+
"在下面的範例中,我們有一個函式 ``some_function``,它實例化 ``Foo`` 並呼叫它的"
156+
"方法。 對 :func:`patch` 的呼叫將類別 ``Foo`` 替換為一個 mock。``Foo`` 實例是"
157+
"呼叫 mock 的結果,因此它是透過修改 mock :attr:`~Mock.return_value` 來配置"
158+
"的。: ::"
152159

153160
#: ../../library/unittest.mock-examples.rst:130
154161
msgid "Naming your mocks"
155-
msgstr ""
162+
msgstr "命名你的 mock"
156163

157164
#: ../../library/unittest.mock-examples.rst:132
158165
msgid ""
159166
"It can be useful to give your mocks a name. The name is shown in the repr of "
160167
"the mock and can be helpful when the mock appears in test failure messages. "
161168
"The name is also propagated to attributes or methods of the mock:"
162169
msgstr ""
170+
"為你的 mock 命名可能會很有用。 這個名稱會顯示在 mock 的 repr 中,且當 mock 出"
171+
"現在測試的失敗訊息中時,名稱會很有幫助。 該名稱也會傳播到 mock 的屬性或方法:"
163172

164173
#: ../../library/unittest.mock-examples.rst:144
165174
msgid "Tracking all Calls"
166-
msgstr ""
175+
msgstr "追蹤所有呼叫"
167176

168177
#: ../../library/unittest.mock-examples.rst:146
169178
msgid ""
170179
"Often you want to track more than a single call to a method. The :attr:"
171180
"`~Mock.mock_calls` attribute records all calls to child attributes of the "
172181
"mock - and also to their children."
173182
msgstr ""
183+
"通常你會想要追蹤對一個方法的多個呼叫。:attr:`~Mock.mock_calls` 屬性記錄對 "
184+
"mock 的子屬性以及其子屬性的所有呼叫。"
174185

175186
#: ../../library/unittest.mock-examples.rst:158
176187
msgid ""
@@ -179,58 +190,69 @@ msgid ""
179190
"well as asserting that the calls you expected have been made, you are also "
180191
"checking that they were made in the right order and with no additional calls:"
181192
msgstr ""
193+
"如果你對 ``mock_calls`` 做出斷言並且有任何不預期的方法被呼叫,則斷言將失敗。 "
194+
"這很有用,因為除了斷言你期望的呼叫已經進行之外,你還可以檢查它們是否按正確的"
195+
"順序進行,並且沒有多餘的呼叫:"
182196

183197
#: ../../library/unittest.mock-examples.rst:163
184198
msgid ""
185199
"You use the :data:`call` object to construct lists for comparing with "
186200
"``mock_calls``:"
187-
msgstr ""
201+
msgstr "你可以使用 :data:`call` 物件來建構串列以與 ``mock_calls`` 進行比較:"
188202

189203
#: ../../library/unittest.mock-examples.rst:170
190204
msgid ""
191205
"However, parameters to calls that return mocks are not recorded, which means "
192206
"it is not possible to track nested calls where the parameters used to create "
193207
"ancestors are important:"
194208
msgstr ""
209+
"然而,回傳 mock 的呼叫的參數不會被記錄,這代表著無法追蹤用於建立重要的祖先的"
210+
"參數的巢狀呼叫:"
195211

196212
#: ../../library/unittest.mock-examples.rst:181
197213
msgid "Setting Return Values and Attributes"
198-
msgstr ""
214+
msgstr "設定回傳值和屬性"
199215

200216
#: ../../library/unittest.mock-examples.rst:183
201217
msgid "Setting the return values on a mock object is trivially easy:"
202-
msgstr ""
218+
msgstr "在 mock 物件上設定回傳值非常簡單:"
203219

204220
#: ../../library/unittest.mock-examples.rst:190
205221
msgid "Of course you can do the same for methods on the mock:"
206-
msgstr ""
222+
msgstr "當然,你可以對 mock 上的方法執行相同的操作:"
207223

208224
#: ../../library/unittest.mock-examples.rst:197
209225
msgid "The return value can also be set in the constructor:"
210-
msgstr ""
226+
msgstr "回傳值也可以在建構函式中設定:"
211227

212228
#: ../../library/unittest.mock-examples.rst:203
213229
msgid "If you need an attribute setting on your mock, just do it:"
214-
msgstr ""
230+
msgstr "如果你需要在 mock 上進行屬性設置,只需執行以下操作:"
215231

216232
#: ../../library/unittest.mock-examples.rst:210
217233
msgid ""
218234
"Sometimes you want to mock up a more complex situation, like for example "
219235
"``mock.connection.cursor().execute(\"SELECT 1\")``. If we wanted this call "
220236
"to return a list, then we have to configure the result of the nested call."
221237
msgstr ""
238+
"有時你想要 mock 更複雜的情況,例如 ``mock.connection.cursor()."
239+
"execute(\"SELECT 1\")``。 如果我們希望此呼叫回傳一個串列,那麼我們就必須配置"
240+
"巢狀呼叫的結果。"
222241

223242
#: ../../library/unittest.mock-examples.rst:214
224243
msgid ""
225244
"We can use :data:`call` to construct the set of calls in a \"chained call\" "
226245
"like this for easy assertion afterwards:"
227246
msgstr ""
247+
"如下所示,我們可以使用 :data:`call` 在「鍊接呼叫 (chained call)」中建構呼叫的"
248+
"集合,以便在之後輕鬆的進行斷言:"
228249

229250
#: ../../library/unittest.mock-examples.rst:228
230251
msgid ""
231252
"It is the call to ``.call_list()`` that turns our call object into a list of "
232253
"calls representing the chained calls."
233254
msgstr ""
255+
"正是對 ``.call_list()`` 的呼叫將我們的呼叫物件轉換為代表鍊接呼叫的呼叫串列。"
234256

235257
#: ../../library/unittest.mock-examples.rst:233
236258
msgid "Raising exceptions with mocks"

0 commit comments

Comments
 (0)