@@ -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-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 "
12
12
"
Last-Translator :
Liang-Bo Wang <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -17,49 +17,56 @@ msgstr ""
17
17
"Content-Type : text/plain; charset=UTF-8\n "
18
18
"Content-Transfer-Encoding : 8bit\n "
19
19
"Plural-Forms : nplurals=1; plural=0;\n "
20
+ "X-Generator : Poedit 3.4\n "
20
21
21
22
#: ../../library/unittest.mock-examples.rst:2
22
23
msgid ":mod:`unittest.mock` --- getting started"
23
- msgstr ""
24
+ msgstr ":mod:`unittest.mock` --- 入門指南 "
24
25
25
26
#: ../../library/unittest.mock-examples.rst:27
26
27
msgid "Using Mock"
27
- msgstr ""
28
+ msgstr "使用 Mock 的方式 "
28
29
29
30
#: ../../library/unittest.mock-examples.rst:30
30
31
msgid "Mock Patching Methods"
31
- msgstr ""
32
+ msgstr "使用 Mock 來 patching 方法 "
32
33
33
34
#: ../../library/unittest.mock-examples.rst:32
34
35
msgid "Common uses for :class:`Mock` objects include:"
35
- msgstr ""
36
+ msgstr ":class:`Mock` 物件的常見用法包含: "
36
37
37
38
#: ../../library/unittest.mock-examples.rst:34
38
39
msgid "Patching methods"
39
- msgstr ""
40
+ msgstr "Patching 方法 "
40
41
41
42
#: ../../library/unittest.mock-examples.rst:35
42
43
msgid "Recording method calls on objects"
43
- msgstr ""
44
+ msgstr "記錄在物件上的方法呼叫 "
44
45
45
46
#: ../../library/unittest.mock-examples.rst:37
46
47
msgid ""
47
48
"You might want to replace a method on an object to check that it is called "
48
49
"with the correct arguments by another part of the system:"
49
50
msgstr ""
51
+ "你可能會想要取代一個物件上的方法,以便檢查系統的另一部分是否使用正確的引數呼"
52
+ "叫它:"
50
53
51
54
#: ../../library/unittest.mock-examples.rst:45
52
55
msgid ""
53
56
"Once our mock has been used (``real.method`` in this example) it has methods "
54
57
"and attributes that allow you to make assertions about how it has been used."
55
58
msgstr ""
59
+ "一旦我們的 mock 已經被使用(例如在這個範例中的 ``real.method``\\ ),它就有了"
60
+ "方法和屬性,允許你對其使用方式進行斷言 (assertions)。"
56
61
57
62
#: ../../library/unittest.mock-examples.rst:50
58
63
msgid ""
59
64
"In most of these examples the :class:`Mock` and :class:`MagicMock` classes "
60
65
"are interchangeable. As the ``MagicMock`` is the more capable class it makes "
61
66
"a sensible one to use by default."
62
67
msgstr ""
68
+ "在大多數的範例中,:class:`Mock` 和 :class:`MagicMock` 類別是可以互換的。不過"
69
+ "由於 ``MagicMock`` 是功能更強大的類別,因此通常它是一個更好的選擇。"
63
70
64
71
#: ../../library/unittest.mock-examples.rst:54
65
72
msgid ""
@@ -68,16 +75,21 @@ msgid ""
68
75
"or :meth:`~Mock.assert_called_once_with` method to check that it was called "
69
76
"with the correct arguments."
70
77
msgstr ""
78
+ "一旦 mock 被呼叫,它的 :attr:`~Mock.called` 屬性將被設定為 ``True``。更重要的"
79
+ "是,我們可以使用 :meth:`~Mock.assert_called_with` 或 :meth:`~Mock."
80
+ "assert_called_once_with` 方法來檢查它是否被使用正確的引數來呼叫。"
71
81
72
82
#: ../../library/unittest.mock-examples.rst:59
73
83
msgid ""
74
84
"This example tests that calling ``ProductionClass().method`` results in a "
75
85
"call to the ``something`` method:"
76
86
msgstr ""
87
+ "這個範例測試呼叫 ``ProductionClass().method`` 是否導致對 ``something`` 方法的"
88
+ "呼叫:"
77
89
78
90
#: ../../library/unittest.mock-examples.rst:76
79
91
msgid "Mock for Method Calls on an Object"
80
- msgstr ""
92
+ msgstr "對物件的方法呼叫使用 mock "
81
93
82
94
#: ../../library/unittest.mock-examples.rst:78
83
95
msgid ""
@@ -86,18 +98,25 @@ msgid ""
86
98
"method (or some part of the system under test) and then check that it is "
87
99
"used in the correct way."
88
100
msgstr ""
101
+ "在上一個範例中,我們直接對物件上的方法進行 patch,以檢查它是否被正確呼叫。另"
102
+ "一個常見的用法是將一個物件傳遞給一個方法(或受測系統的某一部分),然後檢查它"
103
+ "是否以正確的方式被使用。"
89
104
90
105
#: ../../library/unittest.mock-examples.rst:83
91
106
msgid ""
92
107
"The simple ``ProductionClass`` below has a ``closer`` method. If it is "
93
108
"called with an object then it calls ``close`` on it."
94
109
msgstr ""
110
+ "下面是一個單純的 ``ProductionClass``,含有一個 ``closer`` 方法。如果它被傳入"
111
+ "一個物件,它就會呼叫此物件中的 ``close``。"
95
112
96
113
#: ../../library/unittest.mock-examples.rst:91
97
114
msgid ""
98
115
"So to test it we need to pass in an object with a ``close`` method and check "
99
116
"that it was called correctly."
100
117
msgstr ""
118
+ "因此,為了對此進行測試,我們需要傳遞一個具有 ``close`` 方法的物件,並檢查它是"
119
+ "否被正確的呼叫。"
101
120
102
121
#: ../../library/unittest.mock-examples.rst:99
103
122
msgid ""
@@ -106,6 +125,9 @@ msgid ""
106
125
"accessing it in the test will create it, but :meth:`~Mock."
107
126
"assert_called_with` will raise a failure exception."
108
127
msgstr ""
128
+ "我們不必做任何額外的事情來為 mock 提供 'close' 方法,存取 close 會建立它。因"
129
+ "此,如果 'close' 並未被呼叫過,在測試中存取 'close' 就會建立它,但 :meth:"
130
+ "`~Mock.assert_called_with` 就會引發一個失敗的例外。"
109
131
110
132
#: ../../library/unittest.mock-examples.rst:106
111
133
msgid "Mocking Classes"
0 commit comments