@@ -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 : 2024-03-11 22:03 +0800\n "
11
+ "PO-Revision-Date : 2024-03-12 21:41 +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 "
@@ -905,20 +905,23 @@ msgstr ""
905
905
msgid ""
906
906
"Here's some example code that shows the problem. Imagine the following "
907
907
"functions defined in 'mymodule'::"
908
- msgstr ""
908
+ msgstr "這是一些秀出問題的程式碼範例。 想像 'mymodule' 中定義以下函式: :: "
909
909
910
910
#: ../../library/unittest.mock-examples.rst:843
911
911
msgid ""
912
912
"When we try to test that ``grob`` calls ``frob`` with the correct argument "
913
913
"look what happens::"
914
914
msgstr ""
915
+ "當我們嘗試測試 ``grob`` 使用正確的引數呼叫 ``frob`` 時,看看會發生什麼: ::"
915
916
916
917
#: ../../library/unittest.mock-examples.rst:858
917
918
msgid ""
918
919
"One possibility would be for mock to copy the arguments you pass in. This "
919
920
"could then cause problems if you do assertions that rely on object identity "
920
921
"for equality."
921
922
msgstr ""
923
+ "一種可能是讓 mock 複製你傳入的引數。如果你為了相等性執行依賴於物件識別性的斷"
924
+ "言,這可能會導致問題。"
922
925
923
926
#: ../../library/unittest.mock-examples.rst:862
924
927
msgid ""
@@ -930,27 +933,39 @@ msgid ""
930
933
"methods for doing the assertion. Again a helper function sets this up for "
931
934
"me. ::"
932
935
msgstr ""
936
+ "以下是一種使用 :attr:`~Mock.side_effect` 功能的解法。如果你為 mock 提供一個 "
937
+ "``side_effect`` 函式,則 ``side_effect`` 將被使用與 mock 相同的引數呼叫。這使"
938
+ "我們有機會複製引數並將其儲存以供之後的斷言。在這個範例中,我們使用\\ *另一個"
939
+ "* mock 來儲存引數,以便我們可以使用 mock 方法來執行斷言。同樣的,有一個輔助函"
940
+ "式為我們設定了這些。: ::"
933
941
934
942
#: ../../library/unittest.mock-examples.rst:891
935
943
msgid ""
936
944
"``copy_call_args`` is called with the mock that will be called. It returns a "
937
945
"new mock that we do the assertion on. The ``side_effect`` function makes a "
938
946
"copy of the args and calls our ``new_mock`` with the copy."
939
947
msgstr ""
948
+ "``copy_call_args`` 與將要被呼叫的 mock 一起被呼叫。它回傳一個我們會對其進行斷"
949
+ "言的新的 mock。``side_effect`` 函式建立引數們的副本,並用該副本呼叫我們的 "
950
+ "``new_mock``。"
940
951
941
952
#: ../../library/unittest.mock-examples.rst:897
942
953
msgid ""
943
954
"If your mock is only going to be used once there is an easier way of "
944
955
"checking arguments at the point they are called. You can simply do the "
945
956
"checking inside a ``side_effect`` function."
946
957
msgstr ""
958
+ "如果你的 mock 只會被使用一次,則有一種更簡單的方法可以在呼叫引數時檢查它們。"
959
+ "你可以簡單地在 ``side_effect`` 函式內進行檢查。"
947
960
948
961
#: ../../library/unittest.mock-examples.rst:911
949
962
msgid ""
950
963
"An alternative approach is to create a subclass of :class:`Mock` or :class:"
951
964
"`MagicMock` that copies (using :func:`copy.deepcopy`) the arguments. Here's "
952
965
"an example implementation:"
953
966
msgstr ""
967
+ "另一種方法是建立 :class:`Mock` 或 :class:`MagicMock` 的子類別來複製(使用 :"
968
+ "func:`copy.deepcopy`\\ )引數。這是一個實作的例子:"
954
969
955
970
#: ../../library/unittest.mock-examples.rst:935
956
971
msgid ""
@@ -959,6 +974,9 @@ msgid ""
959
974
"That means all children of a ``CopyingMock`` will also have the type "
960
975
"``CopyingMock``."
961
976
msgstr ""
977
+ "當你將 ``Mock`` 或 ``MagicMock`` 子類別化時,所有屬性會被動態建立,且 "
978
+ "``return_value`` 會自動使用你的子類別。這代表著 ``CopyingMock`` 的所有子代 "
979
+ "(child) 也會具有``CopyingMock`` 型別。"
962
980
963
981
#: ../../library/unittest.mock-examples.rst:941
964
982
msgid "Nesting Patches"
0 commit comments