@@ -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 <me@liang2.tw>\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
2223msgid ":mod:`unittest.mock` --- getting started"
23- msgstr ""
24+ msgstr ":mod:`unittest.mock` --- 入門指南 "
2425
2526#: ../../library/unittest.mock-examples.rst:27
2627msgid "Using Mock"
27- msgstr ""
28+ msgstr "使用 Mock 的方式 "
2829
2930#: ../../library/unittest.mock-examples.rst:30
3031msgid "Mock Patching Methods"
31- msgstr ""
32+ msgstr "使用 Mock 來 patching 方法 "
3233
3334#: ../../library/unittest.mock-examples.rst:32
3435msgid "Common uses for :class:`Mock` objects include:"
35- msgstr ""
36+ msgstr ":class:`Mock` 物件的常見用法包含: "
3637
3738#: ../../library/unittest.mock-examples.rst:34
3839msgid "Patching methods"
39- msgstr ""
40+ msgstr "Patching 方法 "
4041
4142#: ../../library/unittest.mock-examples.rst:35
4243msgid "Recording method calls on objects"
43- msgstr ""
44+ msgstr "記錄在物件上的方法呼叫 "
4445
4546#: ../../library/unittest.mock-examples.rst:37
4647msgid ""
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:"
4950msgstr ""
51+ "你可能會想要取代一個物件上的方法,以便檢查系統的另一部分是否使用正確的引數呼"
52+ "叫它:"
5053
5154#: ../../library/unittest.mock-examples.rst:45
5255msgid ""
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."
5558msgstr ""
59+ "一旦我們的 mock 已經被使用(例如在這個範例中的 ``real.method``\\ ),它就有了"
60+ "方法和屬性,允許你對其使用方式進行斷言 (assertions)。"
5661
5762#: ../../library/unittest.mock-examples.rst:50
5863msgid ""
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."
6267msgstr ""
68+ "在大多數的範例中,:class:`Mock` 和 :class:`MagicMock` 類別是可以互換的。不過"
69+ "由於 ``MagicMock`` 是功能更強大的類別,因此通常它是一個更好的選擇。"
6370
6471#: ../../library/unittest.mock-examples.rst:54
6572msgid ""
@@ -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."
7077msgstr ""
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
7383msgid ""
7484"This example tests that calling ``ProductionClass().method`` results in a "
7585"call to the ``something`` method:"
7686msgstr ""
87+ "這個範例測試呼叫 ``ProductionClass().method`` 是否導致對 ``something`` 方法的"
88+ "呼叫:"
7789
7890#: ../../library/unittest.mock-examples.rst:76
7991msgid "Mock for Method Calls on an Object"
80- msgstr ""
92+ msgstr "對物件的方法呼叫使用 mock "
8193
8294#: ../../library/unittest.mock-examples.rst:78
8395msgid ""
@@ -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."
88100msgstr ""
101+ "在上一個範例中,我們直接對物件上的方法進行 patch,以檢查它是否被正確呼叫。另"
102+ "一個常見的用法是將一個物件傳遞給一個方法(或受測系統的某一部分),然後檢查它"
103+ "是否以正確的方式被使用。"
89104
90105#: ../../library/unittest.mock-examples.rst:83
91106msgid ""
92107"The simple ``ProductionClass`` below has a ``closer`` method. If it is "
93108"called with an object then it calls ``close`` on it."
94109msgstr ""
110+ "下面是一個單純的 ``ProductionClass``,含有一個 ``closer`` 方法。如果它被傳入"
111+ "一個物件,它就會呼叫此物件中的 ``close``。"
95112
96113#: ../../library/unittest.mock-examples.rst:91
97114msgid ""
98115"So to test it we need to pass in an object with a ``close`` method and check "
99116"that it was called correctly."
100117msgstr ""
118+ "因此,為了對此進行測試,我們需要傳遞一個具有 ``close`` 方法的物件,並檢查它是"
119+ "否被正確的呼叫。"
101120
102121#: ../../library/unittest.mock-examples.rst:99
103122msgid ""
@@ -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."
108127msgstr ""
128+ "我們不必做任何額外的事情來為 mock 提供 'close' 方法,存取 close 會建立它。因"
129+ "此,如果 'close' 並未被呼叫過,在測試中存取 'close' 就會建立它,但 :meth:"
130+ "`~Mock.assert_called_with` 就會引發一個失敗的例外。"
109131
110132#: ../../library/unittest.mock-examples.rst:106
111133msgid "Mocking Classes"
0 commit comments