Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf231184

Browse files
committed
feat: to rst:448
1 parentb9302b6 commitf231184

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

‎library/unittest.mock-examples.po

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version:Python 3.12\n"
99
"Report-Msgid-Bugs-To:\n"
1010
"POT-Creation-Date:2023-09-09 00:03+0000\n"
11-
"PO-Revision-Date:2024-01-1418:14+0800\n"
11+
"PO-Revision-Date:2024-01-1423:14+0800\n"
1212
"Last-Translator:Liang-Bo Wang <me@liang2.tw>\n"
1313
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -385,25 +385,31 @@ msgstr ""
385385

386386
#:../../library/unittest.mock-examples.rst:364
387387
msgid"Using side_effect to return per file content"
388-
msgstr""
388+
msgstr"使用 side_effect 回傳每一個檔案內容"
389389

390390
#:../../library/unittest.mock-examples.rst:366
391391
msgid""
392392
":func:`mock_open` is used to patch :func:`open` method. :attr:`~Mock."
393393
"side_effect` can be used to return a new Mock object per call. This can be "
394394
"used to return different contents per file stored in a dictionary::"
395395
msgstr""
396+
":func:`mock_open` 是用於 patch :func:`open` 方法。:attr:`~Mock.side_effect` "
397+
"可以用來在每次呼叫回傳一個新的 mock 物件。 這可以用於回傳儲存在字典中的每個檔"
398+
"案的不同內容: ::"
396399

397400
#:../../library/unittest.mock-examples.rst:389
398401
msgid"Patch Decorators"
399-
msgstr""
402+
msgstr"Patch 裝飾器"
400403

401404
#:../../library/unittest.mock-examples.rst:393
402405
msgid""
403406
"With :func:`patch` it matters that you patch objects in the namespace where "
404407
"they are looked up. This is normally straightforward, but for a quick guide "
405408
"read :ref:`where to patch <where-to-patch>`."
406409
msgstr""
410+
"使用 :func:`patch` 時,需注意的是你得在被查找物件的命名空間中(in the "
411+
"namespace where they are looked up)patch 物件。這通常很直接,但若需要快速導"
412+
"引,請參閱\\ :ref:`該 patch 何處 <where-to-patch>`\\ 。"
407413

408414
#:../../library/unittest.mock-examples.rst:398
409415
msgid""
@@ -413,6 +419,10 @@ msgid ""
413419
"on them has to be undone after the test or the patch will persist into other "
414420
"tests and cause hard to diagnose problems."
415421
msgstr""
422+
"測試中的常見需求是 patch 類別屬性或模組屬性,例如 patch 一個內建函式(built-"
423+
"in)或 patch 模組中的類別以測試它是否已實例化。模組和類別實際上是全域的,因此"
424+
"在測試後必須撤銷它們的 patch,否則 patch 將延續到其他測試中並導致難以診斷問"
425+
"題。"
416426

417427
#:../../library/unittest.mock-examples.rst:404
418428
msgid""
@@ -424,25 +434,32 @@ msgid ""
424434
"the name of the attribute you would like patched, plus optionally the value "
425435
"to patch it with."
426436
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 的值。"
427442

428443
#:../../library/unittest.mock-examples.rst:412
429444
msgid"``patch.object``::"
430-
msgstr""
445+
msgstr"``patch.object``: ::"
431446

432447
#:../../library/unittest.mock-examples.rst:429
433448
msgid""
434449
"If you are patching a module (including :mod:`builtins`) then use :func:"
435450
"`patch` instead of :func:`patch.object`:"
436451
msgstr""
452+
"如果你要 patch 一個模組(包括 :mod:`builtins`),請使用 :func:`patch` 而非 :"
453+
"func:`patch.object`:"
437454

438455
#:../../library/unittest.mock-examples.rst:439
439456
msgid""
440457
"The module name can be 'dotted', in the form ``package.module`` if needed::"
441-
msgstr""
458+
msgstr"如有需要,模組名稱可以含有 ``.``,形式為 “package.module”: ::"
442459

443460
#:../../library/unittest.mock-examples.rst:448
444461
msgid"A nice pattern is to actually decorate test methods themselves:"
445-
msgstr""
462+
msgstr"一個好的模式是實際裝飾測試方法本身:"
446463

447464
#:../../library/unittest.mock-examples.rst:459
448465
msgid""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp