Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8dc8166

Browse files
committed
feat: to rst:935
1 parent720d919 commit8dc8166

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

‎library/unittest.mock-examples.po‎

Lines changed: 20 additions & 2 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:2024-03-11 22:03+0800\n"
11+
"PO-Revision-Date:2024-03-12 21:41+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"
@@ -905,20 +905,23 @@ msgstr ""
905905
msgid""
906906
"Here's some example code that shows the problem. Imagine the following "
907907
"functions defined in 'mymodule'::"
908-
msgstr""
908+
msgstr"這是一些秀出問題的程式碼範例。 想像 'mymodule' 中定義以下函式: ::"
909909

910910
#:../../library/unittest.mock-examples.rst:843
911911
msgid""
912912
"When we try to test that ``grob`` calls ``frob`` with the correct argument "
913913
"look what happens::"
914914
msgstr""
915+
"當我們嘗試測試 ``grob`` 使用正確的引數呼叫 ``frob`` 時,看看會發生什麼: ::"
915916

916917
#:../../library/unittest.mock-examples.rst:858
917918
msgid""
918919
"One possibility would be for mock to copy the arguments you pass in. This "
919920
"could then cause problems if you do assertions that rely on object identity "
920921
"for equality."
921922
msgstr""
923+
"一種可能是讓 mock 複製你傳入的引數。如果你為了相等性執行依賴於物件識別性的斷"
924+
"言,這可能會導致問題。"
922925

923926
#:../../library/unittest.mock-examples.rst:862
924927
msgid""
@@ -930,27 +933,39 @@ msgid ""
930933
"methods for doing the assertion. Again a helper function sets this up for "
931934
"me. ::"
932935
msgstr""
936+
"以下是一種使用 :attr:`~Mock.side_effect` 功能的解法。如果你為 mock 提供一個 "
937+
"``side_effect`` 函式,則 ``side_effect`` 將被使用與 mock 相同的引數呼叫。這使"
938+
"我們有機會複製引數並將其儲存以供之後的斷言。在這個範例中,我們使用\\ *另一個"
939+
"* mock 來儲存引數,以便我們可以使用 mock 方法來執行斷言。同樣的,有一個輔助函"
940+
"式為我們設定了這些。: ::"
933941

934942
#:../../library/unittest.mock-examples.rst:891
935943
msgid""
936944
"``copy_call_args`` is called with the mock that will be called. It returns a "
937945
"new mock that we do the assertion on. The ``side_effect`` function makes a "
938946
"copy of the args and calls our ``new_mock`` with the copy."
939947
msgstr""
948+
"``copy_call_args`` 與將要被呼叫的 mock 一起被呼叫。它回傳一個我們會對其進行斷"
949+
"言的新的 mock。``side_effect`` 函式建立引數們的副本,並用該副本呼叫我們的 "
950+
"``new_mock``。"
940951

941952
#:../../library/unittest.mock-examples.rst:897
942953
msgid""
943954
"If your mock is only going to be used once there is an easier way of "
944955
"checking arguments at the point they are called. You can simply do the "
945956
"checking inside a ``side_effect`` function."
946957
msgstr""
958+
"如果你的 mock 只會被使用一次,則有一種更簡單的方法可以在呼叫引數時檢查它們。"
959+
"你可以簡單地在 ``side_effect`` 函式內進行檢查。"
947960

948961
#:../../library/unittest.mock-examples.rst:911
949962
msgid""
950963
"An alternative approach is to create a subclass of :class:`Mock` or :class:"
951964
"`MagicMock` that copies (using :func:`copy.deepcopy`) the arguments. Here's "
952965
"an example implementation:"
953966
msgstr""
967+
"另一種方法是建立 :class:`Mock` 或 :class:`MagicMock` 的子類別來複製(使用 :"
968+
"func:`copy.deepcopy`\\ )引數。這是一個實作的例子:"
954969

955970
#:../../library/unittest.mock-examples.rst:935
956971
msgid""
@@ -959,6 +974,9 @@ msgid ""
959974
"That means all children of a ``CopyingMock`` will also have the type "
960975
"``CopyingMock``."
961976
msgstr""
977+
"當你將 ``Mock`` 或 ``MagicMock`` 子類別化時,所有屬性會被動態建立,且 "
978+
"``return_value`` 會自動使用你的子類別。這代表著 ``CopyingMock`` 的所有子代 "
979+
"(child) 也會具有``CopyingMock`` 型別。"
962980

963981
#:../../library/unittest.mock-examples.rst:941
964982
msgid"Nesting Patches"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp