Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25c3c28

Browse files
committed
docs: mock 翻譯
from rst:498 to 646
1 parent 2f97c31 commit 25c3c28

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

library/unittest.mock.po

Lines changed: 29 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-07-22 00:04+0000\n"
11-
"PO-Revision-Date: 2023-09-26 00:39+0800\n"
11+
"PO-Revision-Date: 2023-09-27 00:27+0800\n"
1212
"Last-Translator: Adrian Liaw <[email protected]>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -554,31 +554,33 @@ msgstr "對於不可呼叫的 mock,將使用可呼叫的變體,而不是任
554554

555555
#: ../../library/unittest.mock.rst:498
556556
msgid "A boolean representing whether or not the mock object has been called:"
557-
msgstr ""
557+
msgstr "一個 boolean(布林),表述 mock 物件是否已經被呼叫:"
558558

559559
#: ../../library/unittest.mock.rst:509
560560
msgid "An integer telling you how many times the mock object has been called:"
561-
msgstr ""
561+
msgstr "一個整數,告訴你 mock 物件被呼叫的次數:"
562562

563563
#: ../../library/unittest.mock.rst:521
564564
msgid "Set this to configure the value returned by calling the mock:"
565-
msgstr ""
565+
msgstr "設定此值以配置呼叫 mock 時回傳的值:"
566566

567567
#: ../../library/unittest.mock.rst:528
568568
msgid ""
569569
"The default return value is a mock object and you can configure it in the "
570570
"normal way:"
571-
msgstr ""
571+
msgstr "預設的回傳值是一個 mock 物件,你也可以按照正常的方式配置它:"
572572

573573
#: ../../library/unittest.mock.rst:537
574574
msgid ":attr:`return_value` can also be set in the constructor:"
575-
msgstr ""
575+
msgstr ":attr:`return_value` 也可以在建構函式中設定:"
576576

577577
#: ../../library/unittest.mock.rst:548
578578
msgid ""
579579
"This can either be a function to be called when the mock is called, an "
580580
"iterable or an exception (class or instance) to be raised."
581581
msgstr ""
582+
"這可以是一個在呼叫 mock 時要呼叫的函式、一個可疊代物件,或者要引發的例外(類"
583+
"別或實例)。"
582584

583585
#: ../../library/unittest.mock.rst:551
584586
msgid ""
@@ -588,6 +590,10 @@ msgid ""
588590
"returns :data:`DEFAULT` then the mock will return its normal value (from "
589591
"the :attr:`return_value`)."
590592
msgstr ""
593+
"如果你傳遞一個函式,它將被呼叫,其引數與 mock 相同,且除非該函式回傳 :data:"
594+
"`DEFAULT` 單例 (singleton),否則對 mock 的呼叫將回傳函式回傳的任何值。如果函"
595+
"式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值(從 :attr:"
596+
"`return_value` 得到)。"
591597

592598
#: ../../library/unittest.mock.rst:557
593599
msgid ""
@@ -596,30 +602,35 @@ msgid ""
596602
"to be raised, or a value to be returned from the call to the mock (:data:"
597603
"`DEFAULT` handling is identical to the function case)."
598604
msgstr ""
605+
"如果你傳遞一個可疊代物件,它將被用於檢索一個疊代器,該疊代器必須在每次呼叫時"
606+
"產出 (yield) 一個值。這個值可以是要引發的例外實例,或者是對 mock 呼叫時要回傳"
607+
"的值(處理 :data:`DEFAULT` 的方式與函式的狀況相同)。"
599608

600609
#: ../../library/unittest.mock.rst:562
601610
msgid ""
602611
"An example of a mock that raises an exception (to test exception handling of "
603612
"an API):"
604-
msgstr ""
613+
msgstr "以下是一個引發例外的 mock 的範例(用於測試 API 的例外處理):"
605614

606615
#: ../../library/unittest.mock.rst:572
607616
msgid "Using :attr:`side_effect` to return a sequence of values:"
608-
msgstr ""
617+
msgstr "使用 :attr:`side_effect` 回傳一連串值的範例:"
609618

610619
#: ../../library/unittest.mock.rst:579
611620
msgid "Using a callable:"
612-
msgstr ""
621+
msgstr "使用可被呼叫物件的範例:"
613622

614623
#: ../../library/unittest.mock.rst:589
615624
msgid ""
616625
":attr:`side_effect` can be set in the constructor. Here's an example that "
617626
"adds one to the value the mock is called with and returns it:"
618627
msgstr ""
628+
":attr:`side_effect` 可以在建構函式中設定。以下是一個範例,它將 mock 被呼叫時"
629+
"給的值加一並回傳:"
619630

620631
#: ../../library/unittest.mock.rst:599
621632
msgid "Setting :attr:`side_effect` to ``None`` clears it:"
622-
msgstr ""
633+
msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它:"
623634

624635
#: ../../library/unittest.mock.rst:613
625636
msgid ""
@@ -630,6 +641,10 @@ msgid ""
630641
"second member, which can also be accessed through the ``kwargs`` property, "
631642
"is any keyword arguments (or an empty dictionary)."
632643
msgstr ""
644+
"這會是 ``None``(如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引數。這"
645+
"將以元組的形式呈現:第一個構件 (member),其可以通過 ``args`` 屬性訪問,是 "
646+
"mock 被呼叫時傳遞的所有有序引數(或一個空元組)。第二個構件,其可以通過 "
647+
"``kwargs`` 屬性訪問,是所有關鍵字引數(或一個空字典)。"
633648

634649
#: ../../library/unittest.mock.rst:646
635650
msgid ""
@@ -638,6 +653,10 @@ msgid ""
638653
"are tuples, so they can be unpacked to get at the individual arguments and "
639654
"make more complex assertions. See :ref:`calls as tuples <calls-as-tuples>`."
640655
msgstr ""
656+
":attr:`call_args`,以及串列 :attr:`call_args_list`、:attr:`method_calls` 和 :"
657+
"attr:`mock_calls` 的構件都是 :data:`call` 物件。這些都是元組,因此可以解包以"
658+
"獲取各個引數並進行更複雜的斷言。參見 :ref:`calls as tuples <calls-as-"
659+
"tuples>`。"
641660

642661
#: ../../library/unittest.mock.rst:652
643662
msgid "Added ``args`` and ``kwargs`` properties."

0 commit comments

Comments
 (0)