@@ -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-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 "
12
12
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -554,31 +554,33 @@ msgstr "對於不可呼叫的 mock,將使用可呼叫的變體,而不是任
554
554
555
555
#: ../../library/unittest.mock.rst:498
556
556
msgid "A boolean representing whether or not the mock object has been called:"
557
- msgstr ""
557
+ msgstr "一個 boolean(布林),表述 mock 物件是否已經被呼叫: "
558
558
559
559
#: ../../library/unittest.mock.rst:509
560
560
msgid "An integer telling you how many times the mock object has been called:"
561
- msgstr ""
561
+ msgstr "一個整數,告訴你 mock 物件被呼叫的次數: "
562
562
563
563
#: ../../library/unittest.mock.rst:521
564
564
msgid "Set this to configure the value returned by calling the mock:"
565
- msgstr ""
565
+ msgstr "設定此值以配置呼叫 mock 時回傳的值: "
566
566
567
567
#: ../../library/unittest.mock.rst:528
568
568
msgid ""
569
569
"The default return value is a mock object and you can configure it in the "
570
570
"normal way:"
571
- msgstr ""
571
+ msgstr "預設的回傳值是一個 mock 物件,你也可以按照正常的方式配置它: "
572
572
573
573
#: ../../library/unittest.mock.rst:537
574
574
msgid ":attr:`return_value` can also be set in the constructor:"
575
- msgstr ""
575
+ msgstr ":attr:`return_value` 也可以在建構函式中設定: "
576
576
577
577
#: ../../library/unittest.mock.rst:548
578
578
msgid ""
579
579
"This can either be a function to be called when the mock is called, an "
580
580
"iterable or an exception (class or instance) to be raised."
581
581
msgstr ""
582
+ "這可以是一個在呼叫 mock 時要呼叫的函式、一個可疊代物件,或者要引發的例外(類"
583
+ "別或實例)。"
582
584
583
585
#: ../../library/unittest.mock.rst:551
584
586
msgid ""
@@ -588,6 +590,10 @@ msgid ""
588
590
"returns :data:`DEFAULT` then the mock will return its normal value (from "
589
591
"the :attr:`return_value`)."
590
592
msgstr ""
593
+ "如果你傳遞一個函式,它將被呼叫,其引數與 mock 相同,且除非該函式回傳 :data:"
594
+ "`DEFAULT` 單例 (singleton),否則對 mock 的呼叫將回傳函式回傳的任何值。如果函"
595
+ "式回傳 :data:`DEFAULT`,那麼 mock 將回傳其正常的回傳值(從 :attr:"
596
+ "`return_value` 得到)。"
591
597
592
598
#: ../../library/unittest.mock.rst:557
593
599
msgid ""
@@ -596,30 +602,35 @@ msgid ""
596
602
"to be raised, or a value to be returned from the call to the mock (:data:"
597
603
"`DEFAULT` handling is identical to the function case)."
598
604
msgstr ""
605
+ "如果你傳遞一個可疊代物件,它將被用於檢索一個疊代器,該疊代器必須在每次呼叫時"
606
+ "產出 (yield) 一個值。這個值可以是要引發的例外實例,或者是對 mock 呼叫時要回傳"
607
+ "的值(處理 :data:`DEFAULT` 的方式與函式的狀況相同)。"
599
608
600
609
#: ../../library/unittest.mock.rst:562
601
610
msgid ""
602
611
"An example of a mock that raises an exception (to test exception handling of "
603
612
"an API):"
604
- msgstr ""
613
+ msgstr "以下是一個引發例外的 mock 的範例(用於測試 API 的例外處理): "
605
614
606
615
#: ../../library/unittest.mock.rst:572
607
616
msgid "Using :attr:`side_effect` to return a sequence of values:"
608
- msgstr ""
617
+ msgstr "使用 :attr:`side_effect` 回傳一連串值的範例: "
609
618
610
619
#: ../../library/unittest.mock.rst:579
611
620
msgid "Using a callable:"
612
- msgstr ""
621
+ msgstr "使用可被呼叫物件的範例: "
613
622
614
623
#: ../../library/unittest.mock.rst:589
615
624
msgid ""
616
625
":attr:`side_effect` can be set in the constructor. Here's an example that "
617
626
"adds one to the value the mock is called with and returns it:"
618
627
msgstr ""
628
+ ":attr:`side_effect` 可以在建構函式中設定。以下是一個範例,它將 mock 被呼叫時"
629
+ "給的值加一並回傳:"
619
630
620
631
#: ../../library/unittest.mock.rst:599
621
632
msgid "Setting :attr:`side_effect` to ``None`` clears it:"
622
- msgstr ""
633
+ msgstr "將 :attr:`side_effect` 設定為 ``None`` 可以清除它: "
623
634
624
635
#: ../../library/unittest.mock.rst:613
625
636
msgid ""
@@ -630,6 +641,10 @@ msgid ""
630
641
"second member, which can also be accessed through the ``kwargs`` property, "
631
642
"is any keyword arguments (or an empty dictionary)."
632
643
msgstr ""
644
+ "這會是 ``None``(如果 mock 尚未被呼叫),或是 mock 上次被呼叫時使用的引數。這"
645
+ "將以元組的形式呈現:第一個構件 (member),其可以通過 ``args`` 屬性訪問,是 "
646
+ "mock 被呼叫時傳遞的所有有序引數(或一個空元組)。第二個構件,其可以通過 "
647
+ "``kwargs`` 屬性訪問,是所有關鍵字引數(或一個空字典)。"
633
648
634
649
#: ../../library/unittest.mock.rst:646
635
650
msgid ""
@@ -638,6 +653,10 @@ msgid ""
638
653
"are tuples, so they can be unpacked to get at the individual arguments and "
639
654
"make more complex assertions. See :ref:`calls as tuples <calls-as-tuples>`."
640
655
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>`。"
641
660
642
661
#: ../../library/unittest.mock.rst:652
643
662
msgid "Added ``args`` and ``kwargs`` properties."
0 commit comments