@@ -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-17 15:22 +0800\n "
10
+ "PO-Revision-Date :2024-01-19 00:14 +0800\n "
11
11
"Last-Translator :Adrian Liaw <adrianliaw2000@gmail.com>\n "
12
12
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -16,7 +16,7 @@ msgstr ""
16
16
"Content-Type :text/plain; charset=UTF-8\n "
17
17
"Content-Transfer-Encoding :8bit\n "
18
18
"Plural-Forms :nplurals=1; plural=0;\n "
19
- "X-Generator :Poedit 3.4.2 \n "
19
+ "X-Generator :Poedit 3.4.1 \n "
20
20
21
21
#: ../../library/unittest.mock.rst:3
22
22
msgid ":mod:`unittest.mock` --- mock object library"
@@ -1413,19 +1413,24 @@ msgid ""
1413
1413
"If you use *spec* or *spec_set* and :func:`patch` is replacing a *class*, "
1414
1414
"then the return value of the created mock will have the same spec. ::"
1415
1415
msgstr ""
1416
+ "如果你使用 *spec* 或 *spec_set* 且 :func:`patch` 正在取代一個\\ *類別*,那麼"
1417
+ "被建立的 mock 的回傳值將具有相同的規格。: ::"
1416
1418
1417
1419
#: ../../library/unittest.mock.rst:1457
1418
1420
msgid ""
1419
1421
"The *new_callable* argument is useful where you want to use an alternative "
1420
1422
"class to the default :class:`MagicMock` for the created mock. For example, "
1421
1423
"if you wanted a :class:`NonCallableMock` to be used::"
1422
1424
msgstr ""
1425
+ "當你想要為被建立的 mock 使用一個替代的類別取代預設的 :class:`MagicMock` 時,"
1426
+ "*new_callable* 引數非常有用。例如,如果你想要一個 :class:`NonCallableMock` 被"
1427
+ "使用: ::"
1423
1428
1424
1429
#: ../../library/unittest.mock.rst:1470
1425
1430
msgid ""
1426
1431
"Another use case might be to replace an object with an :class:`io.StringIO` "
1427
1432
"instance::"
1428
- msgstr ""
1433
+ msgstr "另一個用法是用一個 :class:`io.StringIO` 實例替換一個物件: :: "
1429
1434
1430
1435
#: ../../library/unittest.mock.rst:1483
1431
1436
msgid ""
@@ -1434,6 +1439,9 @@ msgid ""
1434
1439
"can be done in the call to patch. Any arbitrary keywords you pass into the "
1435
1440
"call will be used to set attributes on the created mock::"
1436
1441
msgstr ""
1442
+ "當 :func:`patch` 為你建立 mock 時,通常你需要做的第一件事就是配置 mock。其中"
1443
+ "一些配置可以在對 patch 的呼叫中完成。你傳遞到呼叫中的任何關鍵字都將用於在被建"
1444
+ "立的 mock 上設定屬性: ::"
1437
1445
1438
1446
#: ../../library/unittest.mock.rst:1495
1439
1447
msgid ""
@@ -1443,25 +1451,34 @@ msgid ""
1443
1451
"arguments, but a dictionary with these as keys can still be expanded into a :"
1444
1452
"func:`patch` call using ``**``::"
1445
1453
msgstr ""
1454
+ "除了被建立的 mock 上的屬性外,還可以配置 child mock 的 :attr:`~Mock."
1455
+ "return_value` 和 :attr:`~Mock.side_effect`。它們在語法上不能直接作為關鍵字引"
1456
+ "數傳入,但是以它們作為鍵的字典仍然可以使用 ``**`` 擴充為一個 :func:`patch` 呼"
1457
+ "叫: ::"
1446
1458
1447
1459
#: ../../library/unittest.mock.rst:1511
1448
1460
msgid ""
1449
1461
"By default, attempting to patch a function in a module (or a method or an "
1450
1462
"attribute in a class) that does not exist will fail with :exc:"
1451
1463
"`AttributeError`::"
1452
1464
msgstr ""
1465
+ "預設情況下,嘗試 patch 模組中不存在的函式(或類別中的方法或屬性)將會失敗,並"
1466
+ "引發 :exc:`AttributeError`: ::"
1453
1467
1454
1468
#: ../../library/unittest.mock.rst:1523
1455
1469
msgid ""
1456
1470
"but adding ``create=True`` in the call to :func:`patch` will make the "
1457
1471
"previous example work as expected::"
1458
1472
msgstr ""
1473
+ "但是在對 :func:`patch` 的呼叫中增加 ``create=True`` 將使前面的範例按照預期運"
1474
+ "作: ::"
1459
1475
1460
1476
#: ../../library/unittest.mock.rst:1534
1461
1477
msgid ""
1462
1478
":func:`patch` now returns an :class:`AsyncMock` if the target is an async "
1463
1479
"function."
1464
1480
msgstr ""
1481
+ "如果目標是一個非同步函式,:func:`patch` 現在會回傳一個 :class:`AsyncMock`。"
1465
1482
1466
1483
#: ../../library/unittest.mock.rst:1538
1467
1484
msgid "patch.object"
@@ -1472,6 +1489,8 @@ msgid ""
1472
1489
"patch the named member (*attribute*) on an object (*target*) with a mock "
1473
1490
"object."
1474
1491
msgstr ""
1492
+ "使用一個 mock 物件 patch 一個物件(\\ *目標*\\ )上的命名成員(\\ *屬性"
1493
+ "*\\ )。"
1475
1494
1476
1495
#: ../../library/unittest.mock.rst:1545
1477
1496
msgid ""
@@ -1481,32 +1500,44 @@ msgid ""
1481
1500
"`patch`, :func:`patch.object` takes arbitrary keyword arguments for "
1482
1501
"configuring the mock object it creates."
1483
1502
msgstr ""
1503
+ ":func:`patch.object` 可以做為裝飾器、類別裝飾器或情境管理器使用。引數 *new*、"
1504
+ "*spec*、*create*、*spec_set*、*autospec* 和 *new_callable* 與 :func:`patch` "
1505
+ "具有相同的意義。與 :func:`patch` 一樣,:func:`patch.object` 接受任意關鍵字引"
1506
+ "數來配置它所建立的 mock 物件。"
1484
1507
1485
1508
#: ../../library/unittest.mock.rst:1551
1486
1509
msgid ""
1487
1510
"When used as a class decorator :func:`patch.object` honours ``patch."
1488
1511
"TEST_PREFIX`` for choosing which methods to wrap."
1489
1512
msgstr ""
1513
+ "當作為類別裝飾器使用時,:func:`patch.object` 會遵循 ``patch.TEST_PREFIX`` 來"
1514
+ "選擇要包裝的方法。"
1490
1515
1491
1516
#: ../../library/unittest.mock.rst:1554
1492
1517
msgid ""
1493
1518
"You can either call :func:`patch.object` with three arguments or two "
1494
1519
"arguments. The three argument form takes the object to be patched, the "
1495
1520
"attribute name and the object to replace the attribute with."
1496
1521
msgstr ""
1522
+ "你可以使用三個引數或兩個引數來呼叫 :func:`patch.object`。三個引數的形式接受要"
1523
+ "被 patch 的物件、屬性名稱和要替換掉屬性的物件。"
1497
1524
1498
1525
#: ../../library/unittest.mock.rst:1558
1499
1526
msgid ""
1500
1527
"When calling with the two argument form you omit the replacement object, and "
1501
1528
"a mock is created for you and passed in as an extra argument to the "
1502
1529
"decorated function:"
1503
1530
msgstr ""
1531
+ "當使用兩個引數的形式呼叫時,你會省略要替換的物件,一個 mock 會為你建立並將其"
1532
+ "作為額外的引數傳遞給被裝飾的函式:"
1504
1533
1505
1534
#: ../../library/unittest.mock.rst:1569
1506
1535
msgid ""
1507
1536
"*spec*, *create* and the other arguments to :func:`patch.object` have the "
1508
1537
"same meaning as they do for :func:`patch`."
1509
1538
msgstr ""
1539
+ "*spec*、*create* 和 :func:`patch.object` 的其他引數與 :func:`patch` 具有相同"
1540
+ "的意義。"
1510
1541
1511
1542
#: ../../library/unittest.mock.rst:1574
1512
1543
msgid "patch.dict"