@@ -7,7 +7,7 @@ msgstr ""
7
7
"Project-Id-Version : Python 3.12\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
9
"POT-Creation-Date : 2023-12-16 00:03+0000\n "
10
- "PO-Revision-Date : 2024-01-20 00:30 +0800\n "
10
+ "PO-Revision-Date : 2024-01-20 22:16 +0800\n "
11
11
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -130,8 +130,8 @@ msgid ""
130
130
"decorators are applied). This means from the bottom up, so in the example "
131
131
"above the mock for ``module.ClassName1`` is passed in first."
132
132
msgstr ""
133
- "當你嵌套 patch 裝飾器時,mock 會以被應用的順序傳遞到裝飾函數(裝飾器應用的正 "
134
- "常 *Python* 順序)。這意味著由下而上,因此在上面的範例中,\\ ``module."
133
+ "當你巢狀使用 patch 裝飾器時,mock 會以被應用的順序傳遞到裝飾函數(裝飾器應用 "
134
+ "的正常 *Python* 順序)。這意味著由下而上,因此在上面的範例中,\\ ``module."
135
135
"ClassName1`` 的 mock 會先被傳入。"
136
136
137
137
#: ../../library/unittest.mock.rst:122
@@ -722,7 +722,7 @@ msgid ""
722
722
"made, the parameters of ancestor calls are not recorded and so will always "
723
723
"compare equal:"
724
724
msgstr ""
725
- ":attr:`mock_calls` 記錄的方式意味著在進行嵌套呼叫時 ,上代 (ancestor) 呼叫的參"
725
+ ":attr:`mock_calls` 記錄的方式意味著在進行巢狀呼叫時 ,上代 (ancestor) 呼叫的參"
726
726
"數不會被記錄,因此在比較時它們將始終相等:"
727
727
728
728
#: ../../library/unittest.mock.rst:737
@@ -1611,7 +1611,7 @@ msgid ""
1611
1611
"details about how to change the value of see :ref:`test-prefix`."
1612
1612
msgstr ""
1613
1613
"如果你想在測試中使用不同的前綴,你可以透過設定 ``patch.TEST_PREFIX`` 來告知 "
1614
- "patch 使用不同的前綴。請參閱 :ref:`test-prefix` 以得知如何修改前綴的更多內"
1614
+ "patcher 使用不同的前綴。請參閱 :ref:`test-prefix` 以得知如何修改前綴的更多內"
1615
1615
"容。"
1616
1616
1617
1617
#: ../../library/unittest.mock.rst:1628
@@ -1705,8 +1705,8 @@ msgid ""
1705
1705
"put arguments passed by keyword *after* any of the standard arguments "
1706
1706
"created by :func:`patch`::"
1707
1707
msgstr ""
1708
- ":func:`patch.multiple` 可以與其他 ``patch`` 裝飾器嵌套,但需要將透過關鍵字傳 "
1709
- "遞的引數放在 :func:`patch` 建立的任何標準引數/ *之後*/ : ::"
1708
+ ":func:`patch.multiple` 可以與其他 ``patch`` 裝飾器巢狀使用,但需要將透過關鍵 "
1709
+ "字傳遞的引數放在 :func:`patch` 建立的任何標準引數/ *之後*/ : ::"
1710
1710
1711
1711
#: ../../library/unittest.mock.rst:1739
1712
1712
msgid ""
@@ -1727,6 +1727,9 @@ msgid ""
1727
1727
"simpler to do patching in ``setUp`` methods or where you want to do multiple "
1728
1728
"patches without nesting decorators or with statements."
1729
1729
msgstr ""
1730
+ "所有的 patcher 都有 :meth:`start` 與 :meth:`stop` 方法。這使得在 ``setUp`` 方"
1731
+ "法中進行 patch 或在你想要在沒有巢狀使用裝飾器或 with 陳述式的情況下進行多個 "
1732
+ "patch 時變得更簡單。"
1730
1733
1731
1734
#: ../../library/unittest.mock.rst:1759
1732
1735
msgid ""
@@ -1735,18 +1738,25 @@ msgid ""
1735
1738
"then call :meth:`start` to put the patch in place and :meth:`stop` to undo "
1736
1739
"it."
1737
1740
msgstr ""
1741
+ "要使用它們,請像平常一樣呼叫 :func:`patch`、:func:`patch.object` 或 :func:"
1742
+ "`patch.dict` ,並保留對回傳的 ``patcher`` 物件的參照。之後你就可以呼叫 :meth:"
1743
+ "`start` 將 patch 準備就緒,並呼叫 :meth:`stop` 來取消 patch。"
1738
1744
1739
1745
#: ../../library/unittest.mock.rst:1763
1740
1746
msgid ""
1741
1747
"If you are using :func:`patch` to create a mock for you then it will be "
1742
1748
"returned by the call to ``patcher.start``. ::"
1743
1749
msgstr ""
1750
+ "如果你使用 :func:`patch` 為你建立 mock,那麼它將透過呼叫 ``patcher.start`` 回"
1751
+ "傳。: ::"
1744
1752
1745
1753
#: ../../library/unittest.mock.rst:1777
1746
1754
msgid ""
1747
1755
"A typical use case for this might be for doing multiple patches in the "
1748
1756
"``setUp`` method of a :class:`TestCase`::"
1749
1757
msgstr ""
1758
+ "一個典型的用法是在一個 :class:`TestCase` 的 ``setUp`` 方法中執行多個 "
1759
+ "patch: ::"
1750
1760
1751
1761
#: ../../library/unittest.mock.rst:1799
1752
1762
msgid ""
@@ -1755,26 +1765,29 @@ msgid ""
1755
1765
"exception is raised in the ``setUp`` then ``tearDown`` is not called. :meth:"
1756
1766
"`unittest.TestCase.addCleanup` makes this easier::"
1757
1767
msgstr ""
1768
+ "如果你使用這個技巧,你必須確保透過呼叫 ``stop`` 來 \" 取消\" patch。這可能會比"
1769
+ "你想像的還要複雜一點,因為如果有例外在 ``setUp`` 中被引發,則 ``tearDown`` 就"
1770
+ "不會被呼叫。:meth:`unittest.TestCase.addCleanup` 會讓這稍微簡單一點: ::"
1758
1771
1759
1772
#: ../../library/unittest.mock.rst:1814
1760
1773
msgid ""
1761
1774
"As an added bonus you no longer need to keep a reference to the ``patcher`` "
1762
1775
"object."
1763
- msgstr ""
1776
+ msgstr "作為額外的好處,你不再需要保留對 ``patcher`` 物件的參照。 "
1764
1777
1765
1778
#: ../../library/unittest.mock.rst:1817
1766
1779
msgid ""
1767
1780
"It is also possible to stop all patches which have been started by using :"
1768
1781
"func:`patch.stopall`."
1769
- msgstr ""
1782
+ msgstr "也可以使用 :func:`patch.stopall` 來停止所有已啟動的 patch。 "
1770
1783
1771
1784
#: ../../library/unittest.mock.rst:1822
1772
1785
msgid "Stop all active patches. Only stops patches started with ``start``."
1773
- msgstr ""
1786
+ msgstr "停止所有運作的 patch。只停止以 ``start`` 啟動的 patch。 "
1774
1787
1775
1788
#: ../../library/unittest.mock.rst:1828
1776
1789
msgid "patch builtins"
1777
- msgstr ""
1790
+ msgstr "patch 內建函式 "
1778
1791
1779
1792
#: ../../library/unittest.mock.rst:1829
1780
1793
msgid ""
0 commit comments