Skip to content

Commit 3da9ae9

Browse files
committed
feat: to rst:1569
1 parent b813391 commit 3da9ae9

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

library/unittest.mock.po

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version: Python 3.12\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2023-12-16 00:03+0000\n"
10-
"PO-Revision-Date: 2024-01-17 15:22+0800\n"
10+
"PO-Revision-Date: 2024-01-19 00:14+0800\n"
1111
"Last-Translator: Adrian Liaw <[email protected]>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
@@ -16,7 +16,7 @@ msgstr ""
1616
"Content-Type: text/plain; charset=UTF-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
1818
"Plural-Forms: nplurals=1; plural=0;\n"
19-
"X-Generator: Poedit 3.4.2\n"
19+
"X-Generator: Poedit 3.4.1\n"
2020

2121
#: ../../library/unittest.mock.rst:3
2222
msgid ":mod:`unittest.mock` --- mock object library"
@@ -1413,19 +1413,24 @@ msgid ""
14131413
"If you use *spec* or *spec_set* and :func:`patch` is replacing a *class*, "
14141414
"then the return value of the created mock will have the same spec. ::"
14151415
msgstr ""
1416+
"如果你使用 *spec* 或 *spec_set* 且 :func:`patch` 正在取代一個\\ *類別*,那麼"
1417+
"被建立的 mock 的回傳值將具有相同的規格。: ::"
14161418

14171419
#: ../../library/unittest.mock.rst:1457
14181420
msgid ""
14191421
"The *new_callable* argument is useful where you want to use an alternative "
14201422
"class to the default :class:`MagicMock` for the created mock. For example, "
14211423
"if you wanted a :class:`NonCallableMock` to be used::"
14221424
msgstr ""
1425+
"當你想要為被建立的 mock 使用一個替代的類別取代預設的 :class:`MagicMock` 時,"
1426+
"*new_callable* 引數非常有用。例如,如果你想要一個 :class:`NonCallableMock` 被"
1427+
"使用: ::"
14231428

14241429
#: ../../library/unittest.mock.rst:1470
14251430
msgid ""
14261431
"Another use case might be to replace an object with an :class:`io.StringIO` "
14271432
"instance::"
1428-
msgstr ""
1433+
msgstr "另一個用法是用一個 :class:`io.StringIO` 實例替換一個物件: ::"
14291434

14301435
#: ../../library/unittest.mock.rst:1483
14311436
msgid ""
@@ -1434,6 +1439,9 @@ msgid ""
14341439
"can be done in the call to patch. Any arbitrary keywords you pass into the "
14351440
"call will be used to set attributes on the created mock::"
14361441
msgstr ""
1442+
"當 :func:`patch` 為你建立 mock 時,通常你需要做的第一件事就是配置 mock。其中"
1443+
"一些配置可以在對 patch 的呼叫中完成。你傳遞到呼叫中的任何關鍵字都將用於在被建"
1444+
"立的 mock 上設定屬性: ::"
14371445

14381446
#: ../../library/unittest.mock.rst:1495
14391447
msgid ""
@@ -1443,25 +1451,34 @@ msgid ""
14431451
"arguments, but a dictionary with these as keys can still be expanded into a :"
14441452
"func:`patch` call using ``**``::"
14451453
msgstr ""
1454+
"除了被建立的 mock 上的屬性外,還可以配置 child mock 的 :attr:`~Mock."
1455+
"return_value` 和 :attr:`~Mock.side_effect`。它們在語法上不能直接作為關鍵字引"
1456+
"數傳入,但是以它們作為鍵的字典仍然可以使用 ``**`` 擴充為一個 :func:`patch` 呼"
1457+
"叫: ::"
14461458

14471459
#: ../../library/unittest.mock.rst:1511
14481460
msgid ""
14491461
"By default, attempting to patch a function in a module (or a method or an "
14501462
"attribute in a class) that does not exist will fail with :exc:"
14511463
"`AttributeError`::"
14521464
msgstr ""
1465+
"預設情況下,嘗試 patch 模組中不存在的函式(或類別中的方法或屬性)將會失敗,並"
1466+
"引發 :exc:`AttributeError`: ::"
14531467

14541468
#: ../../library/unittest.mock.rst:1523
14551469
msgid ""
14561470
"but adding ``create=True`` in the call to :func:`patch` will make the "
14571471
"previous example work as expected::"
14581472
msgstr ""
1473+
"但是在對 :func:`patch` 的呼叫中增加 ``create=True`` 將使前面的範例按照預期運"
1474+
"作: ::"
14591475

14601476
#: ../../library/unittest.mock.rst:1534
14611477
msgid ""
14621478
":func:`patch` now returns an :class:`AsyncMock` if the target is an async "
14631479
"function."
14641480
msgstr ""
1481+
"如果目標是一個非同步函式,:func:`patch` 現在會回傳一個 :class:`AsyncMock`。"
14651482

14661483
#: ../../library/unittest.mock.rst:1538
14671484
msgid "patch.object"
@@ -1472,6 +1489,8 @@ msgid ""
14721489
"patch the named member (*attribute*) on an object (*target*) with a mock "
14731490
"object."
14741491
msgstr ""
1492+
"使用一個 mock 物件 patch 一個物件(\\ *目標*\\ )上的命名成員(\\ *屬性"
1493+
"*\\ )。"
14751494

14761495
#: ../../library/unittest.mock.rst:1545
14771496
msgid ""
@@ -1481,32 +1500,44 @@ msgid ""
14811500
"`patch`, :func:`patch.object` takes arbitrary keyword arguments for "
14821501
"configuring the mock object it creates."
14831502
msgstr ""
1503+
":func:`patch.object` 可以做為裝飾器、類別裝飾器或情境管理器使用。引數 *new*、"
1504+
"*spec*、*create*、*spec_set*、*autospec* 和 *new_callable* 與 :func:`patch` "
1505+
"具有相同的意義。與 :func:`patch` 一樣,:func:`patch.object` 接受任意關鍵字引"
1506+
"數來配置它所建立的 mock 物件。"
14841507

14851508
#: ../../library/unittest.mock.rst:1551
14861509
msgid ""
14871510
"When used as a class decorator :func:`patch.object` honours ``patch."
14881511
"TEST_PREFIX`` for choosing which methods to wrap."
14891512
msgstr ""
1513+
"當作為類別裝飾器使用時,:func:`patch.object` 會遵循 ``patch.TEST_PREFIX`` 來"
1514+
"選擇要包裝的方法。"
14901515

14911516
#: ../../library/unittest.mock.rst:1554
14921517
msgid ""
14931518
"You can either call :func:`patch.object` with three arguments or two "
14941519
"arguments. The three argument form takes the object to be patched, the "
14951520
"attribute name and the object to replace the attribute with."
14961521
msgstr ""
1522+
"你可以使用三個引數或兩個引數來呼叫 :func:`patch.object`。三個引數的形式接受要"
1523+
"被 patch 的物件、屬性名稱和要替換掉屬性的物件。"
14971524

14981525
#: ../../library/unittest.mock.rst:1558
14991526
msgid ""
15001527
"When calling with the two argument form you omit the replacement object, and "
15011528
"a mock is created for you and passed in as an extra argument to the "
15021529
"decorated function:"
15031530
msgstr ""
1531+
"當使用兩個引數的形式呼叫時,你會省略要替換的物件,一個 mock 會為你建立並將其"
1532+
"作為額外的引數傳遞給被裝飾的函式:"
15041533

15051534
#: ../../library/unittest.mock.rst:1569
15061535
msgid ""
15071536
"*spec*, *create* and the other arguments to :func:`patch.object` have the "
15081537
"same meaning as they do for :func:`patch`."
15091538
msgstr ""
1539+
"*spec*、*create* 和 :func:`patch.object` 的其他引數與 :func:`patch` 具有相同"
1540+
"的意義。"
15101541

15111542
#: ../../library/unittest.mock.rst:1574
15121543
msgid "patch.dict"

0 commit comments

Comments
 (0)