@@ -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-09-09 00:03+0000\n "
11
- "PO-Revision-Date : 2024-01-14 18 :14+0800\n "
11
+ "PO-Revision-Date : 2024-01-14 23 :14+0800\n "
12
12
"
Last-Translator :
Liang-Bo Wang <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -385,25 +385,31 @@ msgstr ""
385
385
386
386
#: ../../library/unittest.mock-examples.rst:364
387
387
msgid "Using side_effect to return per file content"
388
- msgstr ""
388
+ msgstr "使用 side_effect 回傳每一個檔案內容 "
389
389
390
390
#: ../../library/unittest.mock-examples.rst:366
391
391
msgid ""
392
392
":func:`mock_open` is used to patch :func:`open` method. :attr:`~Mock."
393
393
"side_effect` can be used to return a new Mock object per call. This can be "
394
394
"used to return different contents per file stored in a dictionary::"
395
395
msgstr ""
396
+ ":func:`mock_open` 是用於 patch :func:`open` 方法。:attr:`~Mock.side_effect` "
397
+ "可以用來在每次呼叫回傳一個新的 mock 物件。 這可以用於回傳儲存在字典中的每個檔"
398
+ "案的不同內容: ::"
396
399
397
400
#: ../../library/unittest.mock-examples.rst:389
398
401
msgid "Patch Decorators"
399
- msgstr ""
402
+ msgstr "Patch 裝飾器 "
400
403
401
404
#: ../../library/unittest.mock-examples.rst:393
402
405
msgid ""
403
406
"With :func:`patch` it matters that you patch objects in the namespace where "
404
407
"they are looked up. This is normally straightforward, but for a quick guide "
405
408
"read :ref:`where to patch <where-to-patch>`."
406
409
msgstr ""
410
+ "使用 :func:`patch` 時,需注意的是你得在被查找物件的命名空間中(in the "
411
+ "namespace where they are looked up)patch 物件。這通常很直接,但若需要快速導"
412
+ "引,請參閱\\ :ref:`該 patch 何處 <where-to-patch>`\\ 。"
407
413
408
414
#: ../../library/unittest.mock-examples.rst:398
409
415
msgid ""
@@ -413,6 +419,10 @@ msgid ""
413
419
"on them has to be undone after the test or the patch will persist into other "
414
420
"tests and cause hard to diagnose problems."
415
421
msgstr ""
422
+ "測試中的常見需求是 patch 類別屬性或模組屬性,例如 patch 一個內建函式(built-"
423
+ "in)或 patch 模組中的類別以測試它是否已實例化。模組和類別實際上是全域的,因此"
424
+ "在測試後必須撤銷它們的 patch,否則 patch 將延續到其他測試中並導致難以診斷問"
425
+ "題。"
416
426
417
427
#: ../../library/unittest.mock-examples.rst:404
418
428
msgid ""
@@ -424,25 +434,32 @@ msgid ""
424
434
"the name of the attribute you would like patched, plus optionally the value "
425
435
"to patch it with."
426
436
msgstr ""
437
+ "mock 為此提供了三個方便的裝飾器::func:`patch`、:func:`patch.object` 和 :"
438
+ "func:`patch.dict`。``patch`` 採用單一字串,格式為 ``package.module.Class."
439
+ "attribute``,用來指定要 patch 的屬性。同時它也可以接受你想要替換的屬性(或類"
440
+ "別或其他)的值。``patch.object`` 接受一個物件和你想要 patch 的屬性的名稱,同"
441
+ "時接受要 patch 的值。"
427
442
428
443
#: ../../library/unittest.mock-examples.rst:412
429
444
msgid "``patch.object``::"
430
- msgstr ""
445
+ msgstr "``patch.object``: :: "
431
446
432
447
#: ../../library/unittest.mock-examples.rst:429
433
448
msgid ""
434
449
"If you are patching a module (including :mod:`builtins`) then use :func:"
435
450
"`patch` instead of :func:`patch.object`:"
436
451
msgstr ""
452
+ "如果你要 patch 一個模組(包括 :mod:`builtins`),請使用 :func:`patch` 而非 :"
453
+ "func:`patch.object`:"
437
454
438
455
#: ../../library/unittest.mock-examples.rst:439
439
456
msgid ""
440
457
"The module name can be 'dotted', in the form ``package.module`` if needed::"
441
- msgstr ""
458
+ msgstr "如有需要,模組名稱可以含有 ``.``,形式為 “package.module”: :: "
442
459
443
460
#: ../../library/unittest.mock-examples.rst:448
444
461
msgid "A nice pattern is to actually decorate test methods themselves:"
445
- msgstr ""
462
+ msgstr "一個好的模式是實際裝飾測試方法本身: "
446
463
447
464
#: ../../library/unittest.mock-examples.rst:459
448
465
msgid ""
0 commit comments