Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3812c6

Browse files
[po] auto sync
1 parent 77f3d86 commit c3812c6

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

library/unittest.mock-examples.po

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ msgid ""
372372
"they are looked up. This is normally straightforward, but for a quick guide "
373373
"read :ref:`where to patch <where-to-patch>`."
374374
msgstr ""
375-
"在查找对象的名称空间中修补对象使用 :func:`patch` 。使用起来很简单,阅读 :ref:`在哪里打补丁 <where-to-patch>` "
375+
"在查找对象的名称空间中修补对象使用 :func:`patch` 。使用起来很简单,阅读 :ref:`补丁的位置 <where-to-patch>` "
376376
"来快速上手。"
377377

378378
#: ../../library/unittest.mock-examples.rst:374
@@ -597,12 +597,17 @@ msgid ""
597597
"When the mock date class is called a real date will be constructed and "
598598
"returned by ``side_effect``. ::"
599599
msgstr ""
600+
"这里使用 :func:`patch 装饰器 <patch>` 来模拟被测试模块中的 ``date`` 类。 模拟 date 类中的 "
601+
":attr:`side_effect` 属性随后被设为一个返回真实日期的 lambda 函数。 当模拟 date 类被调用时将由 "
602+
"``side_effect`` 构造并返回一个真实日期。 ::"
600603

601604
#: ../../library/unittest.mock-examples.rst:602
602605
msgid ""
603606
"Note that we don't patch :class:`datetime.date` globally, we patch ``date`` "
604607
"in the module that *uses* it. See :ref:`where to patch <where-to-patch>`."
605608
msgstr ""
609+
"请注意我们没有在全局范围上修补 :class:`datetime.date`,我们只是在 *使用* 它的模块中给 ``date`` 打补丁。 参见 "
610+
":ref:`补丁的位置 <where-to-patch>`。"
606611

607612
#: ../../library/unittest.mock-examples.rst:605
608613
msgid ""
@@ -611,29 +616,34 @@ msgid ""
611616
"find yourself having to calculate an expected result using exactly the same "
612617
"algorithm as the code under test, which is a classic testing anti-pattern."
613618
msgstr ""
619+
"当 ``date.today()`` 被调用时将返回一个已知的日期,但对 ``date(...)`` 构造器的调用仍会返回普通的日期。 "
620+
"如果不是这样你会发现你必须使用与被测试的代码完全相同的算法来计算出预期的结果,这是测试工作中的一个经典的反模式。"
614621

615622
#: ../../library/unittest.mock-examples.rst:610
616623
msgid ""
617624
"Calls to the date constructor are recorded in the ``mock_date`` attributes "
618625
"(``call_count`` and friends) which may also be useful for your tests."
619626
msgstr ""
627+
"对 date 构造器的调用会被记录在 ``mock_date`` 属性中 (``call_count`` 等),它们也可能对你的测试有用处。"
620628

621629
#: ../../library/unittest.mock-examples.rst:613
622630
msgid ""
623631
"An alternative way of dealing with mocking dates, or other builtin classes, "
624632
"is discussed in `this blog entry <https://williambert.online/2011/07/how-to-"
625633
"unit-testing-in-django-with-mocking-and-patching/>`_."
626634
msgstr ""
635+
"有关处理模块日期或其他内置类的一种替代方式的讨论请参见 `这篇博客文章 <https://williambert.online/2011/07/how-"
636+
"to-unit-testing-in-django-with-mocking-and-patching/>`_。"
627637

628638
#: ../../library/unittest.mock-examples.rst:619
629639
msgid "Mocking a Generator Method"
630-
msgstr ""
640+
msgstr "模拟生成器方法"
631641

632642
#: ../../library/unittest.mock-examples.rst:621
633643
msgid ""
634644
"A Python generator is a function or method that uses the :keyword:`yield` "
635645
"statement to return a series of values when iterated over [#]_."
636-
msgstr ""
646+
msgstr "Python 生成器是指在被迭代时使用 :keyword:`yield` 语句来返回一系列值的函数或方法 [#]_。"
637647

638648
#: ../../library/unittest.mock-examples.rst:624
639649
msgid ""
@@ -642,15 +652,17 @@ msgid ""
642652
"iteration is :meth:`~container.__iter__`, so we can mock this using a "
643653
":class:`MagicMock`."
644654
msgstr ""
655+
"调用生成器方法 / 函数将返回生成器对象。 生成器对象随后会被迭代。 迭代操作对应的协议方法是 "
656+
":meth:`~container.__iter__`,因此我们可以使用 :class:`MagicMock` 来模拟它。"
645657

646658
#: ../../library/unittest.mock-examples.rst:629
647659
msgid ""
648660
"Here's an example class with an \"iter\" method implemented as a generator:"
649-
msgstr ""
661+
msgstr "以下是一个使用 \"iter\" 方法模拟为生成器的示例类:"
650662

651663
#: ../../library/unittest.mock-examples.rst:641
652664
msgid "How would we mock this class, and in particular its \"iter\" method?"
653-
msgstr ""
665+
msgstr "我们要如何模拟这个类,特别是它的 \"iter\" 方法呢?"
654666

655667
#: ../../library/unittest.mock-examples.rst:643
656668
msgid ""

library/unittest.mock.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ msgstr ""
16961696

16971697
#: ../../library/unittest.mock.rst:1899
16981698
msgid "Where to patch"
1699-
msgstr "补丁的目标"
1699+
msgstr "补丁的位置"
17001700

17011701
#: ../../library/unittest.mock.rst:1901
17021702
msgid ""

0 commit comments

Comments
 (0)