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

Commit33e687b

Browse files
ken71301mattwang44
authored andcommitted
docs: 翻譯 unittest.mock rst:823至rst:1103 (#735)
Co-authored-by: Wei-Hsiang (Matt) Wang <mattwang44@gmail.com>
1 parent04b1286 commit33e687b

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

‎library/unittest.mock.po

Lines changed: 45 additions & 10 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-10-20 00:03+0000\n"
11-
"PO-Revision-Date:2023-11-23 21:46+0800\n"
11+
"PO-Revision-Date:2023-12-04 21:31+0800\n"
1212
"Last-Translator:Adrian Liaw <adrianliaw2000@gmail.com>\n"
1313
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -827,64 +827,80 @@ msgid ""
827827
"class:`PropertyMock` provides :meth:`__get__` and :meth:`__set__` methods so "
828828
"you can specify a return value when it is fetched."
829829
msgstr""
830+
"一個理應在類別上當成屬性或其他描述器的 mock。:class:`PropertyMock` 提供了 :"
831+
"meth:`__get__` 和 :meth:`__set__` 方法,因此你可以在它被提取時指定回傳值。"
830832

831833
#:../../library/unittest.mock.rst:827
832834
msgid""
833835
"Fetching a :class:`PropertyMock` instance from an object calls the mock, "
834836
"with no args. Setting it calls the mock with the value being set. ::"
835837
msgstr""
838+
"從物件中提取 :class:`PropertyMock` 實例會不帶任何引數呼叫 mock。設定它則會用"
839+
"設定的值來呼叫 mock: ::"
836840

837841
#:../../library/unittest.mock.rst:848
838842
msgid""
839843
"Because of the way mock attributes are stored you can't directly attach a :"
840844
"class:`PropertyMock` to a mock object. Instead you can attach it to the mock "
841845
"type object::"
842846
msgstr""
847+
"由於 mock 屬性的儲存方式,你無法直接將 :class:`PropertyMock` 附加到 mock 物"
848+
"件。但是你可以將其附加到 mock 型別的物件: ::"
843849

844850
#:../../library/unittest.mock.rst:862
845851
msgid""
846852
"An asynchronous version of :class:`MagicMock`. The :class:`AsyncMock` object "
847853
"will behave so the object is recognized as an async function, and the result "
848854
"of a call is an awaitable."
849855
msgstr""
856+
":class:`MagicMock` 的非同步版本。:class:`AsyncMock` 物件的表現將被視為非同步"
857+
"函式,並且呼叫的結果是一個可等待物件。"
850858

851859
#:../../library/unittest.mock.rst:872
852860
msgid""
853861
"The result of ``mock()`` is an async function which will have the outcome of "
854862
"``side_effect`` or ``return_value`` after it has been awaited:"
855863
msgstr""
864+
"``mock()`` 的結果是一個非同步函式,在它被等待後將具有 ``side_effect`` 或 "
865+
"``return_value`` 的結果:"
856866

857867
#:../../library/unittest.mock.rst:875
858868
msgid""
859869
"if ``side_effect`` is a function, the async function will return the result "
860870
"of that function,"
861-
msgstr""
871+
msgstr"如果 ``side_effect`` 是一個函式,非同步函式將回傳該函式的結果,"
862872

863873
#:../../library/unittest.mock.rst:877
864874
msgid""
865875
"if ``side_effect`` is an exception, the async function will raise the "
866876
"exception,"
867-
msgstr""
877+
msgstr"如果 ``side_effect`` 是一個例外,則非同步函式將引發該例外,"
868878

869879
#:../../library/unittest.mock.rst:879
870880
msgid""
871881
"if ``side_effect`` is an iterable, the async function will return the next "
872882
"value of the iterable, however, if the sequence of result is exhausted, "
873883
"``StopAsyncIteration`` is raised immediately,"
874884
msgstr""
885+
"如果 ``side_effect`` 是一個可疊代物件,非同步函式將回傳可疊代物件的下一個值,"
886+
"但如果結果序列耗盡,將立即引發 ``StopAsyncIteration``,"
875887

876888
#:../../library/unittest.mock.rst:882
877889
msgid""
878890
"if ``side_effect`` is not defined, the async function will return the value "
879891
"defined by ``return_value``, hence, by default, the async function returns a "
880892
"new :class:`AsyncMock` object."
881893
msgstr""
894+
"如果 ``side_effect`` 沒有被定義,非同步函式將回傳由 ``return_value`` 定義的"
895+
"值,因此在預設情況下,非同步函式回傳一個新的 :class:`AsyncMock` 物件。"
882896

883897
#:../../library/unittest.mock.rst:887
884898
msgid""
885899
"Setting the *spec* of a :class:`Mock` or :class:`MagicMock` to an async "
886900
"function will result in a coroutine object being returned after calling."
887901
msgstr""
902+
"將 :class:`Mock` 或 :class:`MagicMock` 的 *spec* 設定為非同步函式將導致在呼叫"
903+
"後回傳一個協程物件。"
888904

889905
#:../../library/unittest.mock.rst:899
890906
msgid""
@@ -895,81 +911,100 @@ msgid ""
895911
"or :class:`Mock` (if the parent mock is :class:`Mock`). All asynchronous "
896912
"functions will be :class:`AsyncMock`."
897913
msgstr""
914+
"將 :class:`Mock`、:class:`MagicMock` 或 :class:`AsyncMock` 的 *spec* 設定為具"
915+
"有同步和非同步函式的類別,會自動檢測同步函式並將其設定為 :class:"
916+
"`MagicMock`\\ (如果上代 mock 為 :class:`AsyncMock` 或 :class:"
917+
"`MagicMock`\\ )或 :class:`Mock`\\ (如果上代 mock 為 :class:`Mock`\\ )。所"
918+
"有非同步函式將被設定為 :class:`AsyncMock`。"
898919

899920
#:../../library/unittest.mock.rst:927
900921
msgid""
901922
"Assert that the mock was awaited at least once. Note that this is separate "
902923
"from the object having been called, the ``await`` keyword must be used:"
903924
msgstr""
925+
"斷言 mock 至少被等待過一次。請注意這與物件是否被呼叫是分開的,``await`` 關鍵"
926+
"字必須被使用:"
904927

905928
#:../../library/unittest.mock.rst:946
906929
msgid"Assert that the mock was awaited exactly once."
907-
msgstr""
930+
msgstr"斷言 mock 正好被等待了一次。"
908931

909932
#:../../library/unittest.mock.rst:962
910933
msgid"Assert that the last await was with the specified arguments."
911-
msgstr""
934+
msgstr"斷言最後一次等待使用了指定的引數。"
912935

913936
#:../../library/unittest.mock.rst:979
914937
msgid""
915938
"Assert that the mock was awaited exactly once and with the specified "
916939
"arguments."
917-
msgstr""
940+
msgstr"斷言 mock 只被等待了一次並使用了指定的引數。"
918941

919942
#:../../library/unittest.mock.rst:996
920943
msgid"Assert the mock has ever been awaited with the specified arguments."
921-
msgstr""
944+
msgstr"斷言 mock 曾經被使用指定的引數等待過。"
922945

923946
#:../../library/unittest.mock.rst:1012
924947
msgid""
925948
"Assert the mock has been awaited with the specified calls. The :attr:"
926949
"`await_args_list` list is checked for the awaits."
927950
msgstr""
951+
"斷言 mock 已被使用指定的呼叫進行等待。:attr:`await_args_list` 串列將被檢查以"
952+
"確認等待的內容。"
928953

929954
#:../../library/unittest.mock.rst:1015
930955
msgid""
931956
"If *any_order* is false then the awaits must be sequential. There can be "
932957
"extra calls before or after the specified awaits."
933958
msgstr""
959+
"如果 *any_order* 為 false,則等待必須按照順序。指定的等待之前或之後可以有額外"
960+
"的呼叫。"
934961

935962
#:../../library/unittest.mock.rst:1019
936963
msgid""
937964
"If *any_order* is true then the awaits can be in any order, but they must "
938965
"all appear in :attr:`await_args_list`."
939966
msgstr""
967+
"如果 *any_order* 為 true,則等待可以以任何順序出現,但它們必須全部出現在 :"
968+
"attr:`await_args_list` 中。"
940969

941970
#:../../library/unittest.mock.rst:1039
942971
msgid"Assert that the mock was never awaited."
943-
msgstr""
972+
msgstr"斷言 mock 從未被等待。"
944973

945974
#:../../library/unittest.mock.rst:1046
946975
msgid""
947976
"See :func:`Mock.reset_mock`. Also sets :attr:`await_count` to 0, :attr:"
948977
"`await_args` to None, and clears the :attr:`await_args_list`."
949978
msgstr""
979+
"參見 :func:`Mock.reset_mock`。同時將 :attr:`await_count` 設定為 0,:attr:"
980+
"`await_args` 設定為 None,並清除 :attr:`await_args_list`。"
950981

951982
#:../../library/unittest.mock.rst:1051
952983
msgid""
953984
"An integer keeping track of how many times the mock object has been awaited."
954-
msgstr""
985+
msgstr"一個整數,用來記錄 mock 物件已被等待的次數。"
955986

956987
#:../../library/unittest.mock.rst:1066
957988
msgid""
958989
"This is either ``None`` (if the mock hasn’t been awaited), or the arguments "
959990
"that the mock was last awaited with. Functions the same as :attr:`Mock."
960991
"call_args`."
961992
msgstr""
993+
"這可能是 ``None``\\ (如果 mock 尚未被等待),或者是上次等待 mock 時使用的引"
994+
"數。與 :attr:`Mock.call_args` 的功能相同。"
962995

963996
#:../../library/unittest.mock.rst:1084
964997
msgid""
965998
"This is a list of all the awaits made to the mock object in sequence (so the "
966999
"length of the list is the number of times it has been awaited). Before any "
9671000
"awaits have been made it is an empty list."
9681001
msgstr""
1002+
"這是一個按照順序記錄 mock 物件所有等待的串列(因此串列的長度表示該物件已被等"
1003+
"待的次數)。在進行任何等待之前,此串列為空。"
9691004

9701005
#:../../library/unittest.mock.rst:1103
9711006
msgid"Calling"
972-
msgstr""
1007+
msgstr"呼叫"
9731008

9741009
#:../../library/unittest.mock.rst:1105
9751010
msgid""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp