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

Skip to content

Commit 6b7df87

Browse files
[po] auto sync
1 parent 9203682 commit 6b7df87

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

library/unittest.mock-examples.po

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,8 @@ msgid ""
927927
" and using :data:`~Mock.side_effect` to delegate dictionary access to a real"
928928
" underlying dictionary that is under our control."
929929
msgstr ""
930+
"要做到这点我们可以用 :class:`MagicMock`,它的行为类似于字典,并会使用 :data:`~Mock.side_effect` "
931+
"将字典访问委托给下层的在我们控制之下的一个真正的字典。"
930932

931933
#: ../../library/unittest.mock-examples.rst:974
932934
msgid ""
@@ -935,48 +937,57 @@ msgid ""
935937
"called with the key (and in the case of ``__setitem__`` the value too). We "
936938
"can also control what is returned."
937939
msgstr ""
940+
"当我们的 ``MagicMock`` 的 :meth:`__getitem__` 和 :meth:`__setitem__` "
941+
"方法被调用(即普通的字典访问操作)时 ``side_effect`` 将附带键(对于 ``__setitem__`` 则还将附带值)被调用。 "
942+
"我们也可以控制返回的对象。"
938943

939944
#: ../../library/unittest.mock-examples.rst:978
940945
msgid ""
941946
"After the ``MagicMock`` has been used we can use attributes like "
942947
":data:`~Mock.call_args_list` to assert about how the dictionary was used:"
943948
msgstr ""
949+
"在 ``MagicMock`` 被使用之后我们可以使用 :data:`~Mock.call_args_list` "
950+
"等属性来针对该字典是如何被使用的下断言。"
944951

945952
#: ../../library/unittest.mock-examples.rst:994
946953
msgid ""
947954
"An alternative to using ``MagicMock`` is to use ``Mock`` and *only* provide "
948955
"the magic methods you specifically want:"
949-
msgstr ""
956+
msgstr "``MagicMock`` 的一个可用替代是使用 ``Mock`` 并 *仅仅* 提供你明确需要的魔术方法:"
950957

951958
#: ../../library/unittest.mock-examples.rst:1001
952959
msgid ""
953960
"A *third* option is to use ``MagicMock`` but passing in ``dict`` as the "
954961
"*spec* (or *spec_set*) argument so that the ``MagicMock`` created only has "
955962
"dictionary magic methods available:"
956963
msgstr ""
964+
"*第三个* 选项是使用 ``MagicMock`` 但传入 ``dict`` 作为 *spec* (或 *spec_set*) 参数以使得所创建的 "
965+
"``MagicMock`` 只有字典魔术方法是可用的:"
957966

958967
#: ../../library/unittest.mock-examples.rst:1009
959968
msgid ""
960969
"With these side effect functions in place, the ``mock`` will behave like a "
961970
"normal dictionary but recording the access. It even raises a :exc:`KeyError`"
962971
" if you try to access a key that doesn't exist."
963972
msgstr ""
973+
"通过提供这些附带影响函数,``mock`` 的行为将类似于普通字典但又会记录所有访问。 如果你尝试访问一个不存在的键它甚至会引发 "
974+
":exc:`KeyError`。"
964975

965976
#: ../../library/unittest.mock-examples.rst:1028
966977
msgid ""
967978
"After it has been used you can make assertions about the access using the "
968979
"normal mock methods and attributes:"
969-
msgstr ""
980+
msgstr "在它被使用之后你可以使用普通的 mock 方法和属性进行有关访问操作的断言:"
970981

971982
#: ../../library/unittest.mock-examples.rst:1040
972983
msgid "Mock subclasses and their attributes"
973-
msgstr ""
984+
msgstr "模拟子类及其属性"
974985

975986
#: ../../library/unittest.mock-examples.rst:1042
976987
msgid ""
977988
"There are various reasons why you might want to subclass :class:`Mock`. One "
978989
"reason might be to add helper methods. Here's a silly example:"
979-
msgstr ""
990+
msgstr "你可能出于各种原因想要子类化 :class:`Mock`。 其中一个可能的原因是为了添加辅助方法。 下面是一个笨兮兮的示例:"
980991

981992
#: ../../library/unittest.mock-examples.rst:1058
982993
msgid ""
@@ -987,6 +998,9 @@ msgid ""
987998
"methods then they'll also be available on the attributes and return value "
988999
"mock of instances of your subclass."
9891000
msgstr ""
1001+
"The standard behaviour for ``Mock`` 实例的标准行为是属性和返回值 mock 具有与它们所访问的 mock "
1002+
"相同的类型。 这将确保 ``Mock`` 的属性均为 ``Mocks`` 而 ``MagicMock`` 的属性均为 ``MagicMocks`` "
1003+
"[#]_。 因此如果你通过子类化来添加辅助方法那么它们也将在你的子类的实例的属性和返回值 mock 上可用。"
9901004

9911005
#: ../../library/unittest.mock-examples.rst:1074
9921006
msgid ""

0 commit comments

Comments
 (0)