Skip to content

Commit 4dbeab8

Browse files
ken71301mindihx
andauthored
Translate mock example to rst:99 (#705)
Co-authored-by: mindihx <[email protected]>
1 parent 9187e57 commit 4dbeab8

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

Diff for: library/unittest.mock-examples.po

+30-8
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: 2016-11-19 00:35+0000\n"
11+
"PO-Revision-Date: 2023-11-21 22:16+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,49 +17,56 @@ 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"
2021

2122
#: ../../library/unittest.mock-examples.rst:2
2223
msgid ":mod:`unittest.mock` --- getting started"
23-
msgstr ""
24+
msgstr ":mod:`unittest.mock` --- 入門指南"
2425

2526
#: ../../library/unittest.mock-examples.rst:27
2627
msgid "Using Mock"
27-
msgstr ""
28+
msgstr "使用 Mock 的方式"
2829

2930
#: ../../library/unittest.mock-examples.rst:30
3031
msgid "Mock Patching Methods"
31-
msgstr ""
32+
msgstr "使用 Mock 來 patching 方法"
3233

3334
#: ../../library/unittest.mock-examples.rst:32
3435
msgid "Common uses for :class:`Mock` objects include:"
35-
msgstr ""
36+
msgstr ":class:`Mock` 物件的常見用法包含:"
3637

3738
#: ../../library/unittest.mock-examples.rst:34
3839
msgid "Patching methods"
39-
msgstr ""
40+
msgstr "Patching 方法"
4041

4142
#: ../../library/unittest.mock-examples.rst:35
4243
msgid "Recording method calls on objects"
43-
msgstr ""
44+
msgstr "記錄在物件上的方法呼叫"
4445

4546
#: ../../library/unittest.mock-examples.rst:37
4647
msgid ""
4748
"You might want to replace a method on an object to check that it is called "
4849
"with the correct arguments by another part of the system:"
4950
msgstr ""
51+
"你可能會想要取代一個物件上的方法,以便檢查系統的另一部分是否使用正確的引數呼"
52+
"叫它:"
5053

5154
#: ../../library/unittest.mock-examples.rst:45
5255
msgid ""
5356
"Once our mock has been used (``real.method`` in this example) it has methods "
5457
"and attributes that allow you to make assertions about how it has been used."
5558
msgstr ""
59+
"一旦我們的 mock 已經被使用(例如在這個範例中的 ``real.method``\\ ),它就有了"
60+
"方法和屬性,允許你對其使用方式進行斷言 (assertions)。"
5661

5762
#: ../../library/unittest.mock-examples.rst:50
5863
msgid ""
5964
"In most of these examples the :class:`Mock` and :class:`MagicMock` classes "
6065
"are interchangeable. As the ``MagicMock`` is the more capable class it makes "
6166
"a sensible one to use by default."
6267
msgstr ""
68+
"在大多數的範例中,:class:`Mock` 和 :class:`MagicMock` 類別是可以互換的。不過"
69+
"由於 ``MagicMock`` 是功能更強大的類別,因此通常它是一個更好的選擇。"
6370

6471
#: ../../library/unittest.mock-examples.rst:54
6572
msgid ""
@@ -68,16 +75,21 @@ msgid ""
6875
"or :meth:`~Mock.assert_called_once_with` method to check that it was called "
6976
"with the correct arguments."
7077
msgstr ""
78+
"一旦 mock 被呼叫,它的 :attr:`~Mock.called` 屬性將被設定為 ``True``。更重要的"
79+
"是,我們可以使用 :meth:`~Mock.assert_called_with` 或 :meth:`~Mock."
80+
"assert_called_once_with` 方法來檢查它是否被使用正確的引數來呼叫。"
7181

7282
#: ../../library/unittest.mock-examples.rst:59
7383
msgid ""
7484
"This example tests that calling ``ProductionClass().method`` results in a "
7585
"call to the ``something`` method:"
7686
msgstr ""
87+
"這個範例測試呼叫 ``ProductionClass().method`` 是否導致對 ``something`` 方法的"
88+
"呼叫:"
7789

7890
#: ../../library/unittest.mock-examples.rst:76
7991
msgid "Mock for Method Calls on an Object"
80-
msgstr ""
92+
msgstr "對物件的方法呼叫使用 mock"
8193

8294
#: ../../library/unittest.mock-examples.rst:78
8395
msgid ""
@@ -86,18 +98,25 @@ msgid ""
8698
"method (or some part of the system under test) and then check that it is "
8799
"used in the correct way."
88100
msgstr ""
101+
"在上一個範例中,我們直接對物件上的方法進行 patch,以檢查它是否被正確呼叫。另"
102+
"一個常見的用法是將一個物件傳遞給一個方法(或受測系統的某一部分),然後檢查它"
103+
"是否以正確的方式被使用。"
89104

90105
#: ../../library/unittest.mock-examples.rst:83
91106
msgid ""
92107
"The simple ``ProductionClass`` below has a ``closer`` method. If it is "
93108
"called with an object then it calls ``close`` on it."
94109
msgstr ""
110+
"下面是一個單純的 ``ProductionClass``,含有一個 ``closer`` 方法。如果它被傳入"
111+
"一個物件,它就會呼叫此物件中的 ``close``。"
95112

96113
#: ../../library/unittest.mock-examples.rst:91
97114
msgid ""
98115
"So to test it we need to pass in an object with a ``close`` method and check "
99116
"that it was called correctly."
100117
msgstr ""
118+
"因此,為了對此進行測試,我們需要傳遞一個具有 ``close`` 方法的物件,並檢查它是"
119+
"否被正確的呼叫。"
101120

102121
#: ../../library/unittest.mock-examples.rst:99
103122
msgid ""
@@ -106,6 +125,9 @@ msgid ""
106125
"accessing it in the test will create it, but :meth:`~Mock."
107126
"assert_called_with` will raise a failure exception."
108127
msgstr ""
128+
"我們不必做任何額外的事情來為 mock 提供 'close' 方法,存取 close 會建立它。因"
129+
"此,如果 'close' 並未被呼叫過,在測試中存取 'close' 就會建立它,但 :meth:"
130+
"`~Mock.assert_called_with` 就會引發一個失敗的例外。"
109131

110132
#: ../../library/unittest.mock-examples.rst:106
111133
msgid "Mocking Classes"

0 commit comments

Comments
 (0)