Traduction de library/unittest.mock-examples (#691)

This commit is contained in:
nicolas-roche 2019-12-01 23:51:46 +01:00 committed by Julien Palard
parent 4c75c93ace
commit 7575f95c1c

View File

@ -6,13 +6,14 @@ msgstr ""
"Project-Id-Version: Python 3.6\n" "Project-Id-Version: Python 3.6\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-09 17:54+0200\n" "POT-Creation-Date: 2019-10-09 17:54+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: 2019-12-01 23:32+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n" "Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n" "Language: fr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"X-Generator: Poedit 2.2.1\n"
#: ../Doc/library/unittest.mock-examples.rst:2 #: ../Doc/library/unittest.mock-examples.rst:2
msgid ":mod:`unittest.mock` --- getting started" msgid ":mod:`unittest.mock` --- getting started"
@ -20,35 +21,40 @@ msgstr ""
#: ../Doc/library/unittest.mock-examples.rst:27 #: ../Doc/library/unittest.mock-examples.rst:27
msgid "Using Mock" msgid "Using Mock"
msgstr "" msgstr "Utilisation de Mock ou l'art de singer"
#: ../Doc/library/unittest.mock-examples.rst:30 #: ../Doc/library/unittest.mock-examples.rst:30
msgid "Mock Patching Methods" msgid "Mock Patching Methods"
msgstr "" msgstr "Simulation des méthodes"
#: ../Doc/library/unittest.mock-examples.rst:32 #: ../Doc/library/unittest.mock-examples.rst:32
msgid "Common uses for :class:`Mock` objects include:" msgid "Common uses for :class:`Mock` objects include:"
msgstr "" msgstr "Usages courant de :class:`Mock` :"
#: ../Doc/library/unittest.mock-examples.rst:34 #: ../Doc/library/unittest.mock-examples.rst:34
msgid "Patching methods" msgid "Patching methods"
msgstr "" msgstr "Substitution des méthodes"
#: ../Doc/library/unittest.mock-examples.rst:35 #: ../Doc/library/unittest.mock-examples.rst:35
msgid "Recording method calls on objects" msgid "Recording method calls on objects"
msgstr "" msgstr "Enregistrement des appels faits sur les objets"
#: ../Doc/library/unittest.mock-examples.rst:37 #: ../Doc/library/unittest.mock-examples.rst:37
msgid "" msgid ""
"You might want to replace a method on an object to check that it is called " "You might want to replace a method on an object to check that it is called "
"with the correct arguments by another part of the system:" "with the correct arguments by another part of the system:"
msgstr "" msgstr ""
"On peut remplacer une méthode sur un objet pour contrôler qu'elle est bien "
"appelée avec le nombre correct d'arguments :"
#: ../Doc/library/unittest.mock-examples.rst:45 #: ../Doc/library/unittest.mock-examples.rst:45
msgid "" msgid ""
"Once our mock has been used (``real.method`` in this example) it has methods " "Once our mock has been used (``real.method`` in this example) it has methods "
"and attributes that allow you to make assertions about how it has been used." "and attributes that allow you to make assertions about how it has been used."
msgstr "" msgstr ""
"Une fois notre objet simulacre appelé (via ``real.method`` dans notre "
"exemple), il fournit des méthodes et attributs permettant de valider comment "
"il a été appelé."
#: ../Doc/library/unittest.mock-examples.rst:50 #: ../Doc/library/unittest.mock-examples.rst:50
msgid "" msgid ""
@ -56,6 +62,10 @@ msgid ""
"are interchangeable. As the ``MagicMock`` is the more capable class it makes " "are interchangeable. As the ``MagicMock`` is the more capable class it makes "
"a sensible one to use by default." "a sensible one to use by default."
msgstr "" msgstr ""
"Dans la majeure partie des exemples donnés ici, les classes :class:`Mock` "
"et :class:`MagicMock` sont interchangeables. Étant donné que ``MagicMock`` "
"est la classe la plus puissante des deux, cela fait sens de l'utiliser par "
"défaut."
#: ../Doc/library/unittest.mock-examples.rst:54 #: ../Doc/library/unittest.mock-examples.rst:54
msgid "" msgid ""
@ -64,16 +74,22 @@ msgid ""
"or :meth:`~Mock.assert_called_once_with` method to check that it was called " "or :meth:`~Mock.assert_called_once_with` method to check that it was called "
"with the correct arguments." "with the correct arguments."
msgstr "" msgstr ""
"Une fois l'objet Mock appelé, son attribut :attr:`~Mock.called` est défini à "
"``True``. Qui plus est, nous pouvons utiliser les méthodes :meth:`~Mock."
"assert_called_with` ou :meth:`~Mock.assert_called_once_with` pour contrôler "
"qu'il a été appelé avec les bons arguments."
#: ../Doc/library/unittest.mock-examples.rst:59 #: ../Doc/library/unittest.mock-examples.rst:59
msgid "" msgid ""
"This example tests that calling ``ProductionClass().method`` results in a " "This example tests that calling ``ProductionClass().method`` results in a "
"call to the ``something`` method:" "call to the ``something`` method:"
msgstr "" msgstr ""
"Cet exemple teste que l'appel de la méthode ``ProductionClass().method`` "
"implique bien celui de la méthode ``something`` :"
#: ../Doc/library/unittest.mock-examples.rst:76 #: ../Doc/library/unittest.mock-examples.rst:76
msgid "Mock for Method Calls on an Object" msgid "Mock for Method Calls on an Object"
msgstr "" msgstr "S'assurer de la bonne utilisation d'un objet"
#: ../Doc/library/unittest.mock-examples.rst:78 #: ../Doc/library/unittest.mock-examples.rst:78
msgid "" msgid ""
@ -82,18 +98,27 @@ msgid ""
"method (or some part of the system under test) and then check that it is " "method (or some part of the system under test) and then check that it is "
"used in the correct way." "used in the correct way."
msgstr "" msgstr ""
"Dans l'exemple précédent, nous avons directement remplacé une méthode par un "
"objet (afin de valider que l'appel était correct). Une autre façon de faire "
"est de passer un objet Mock en argument d'une méthode (ou de tout autre "
"partie du code à tester) et ensuite de contrôler que notre objet a été "
"utilisé de la façon attendue."
#: ../Doc/library/unittest.mock-examples.rst:83 #: ../Doc/library/unittest.mock-examples.rst:83
msgid "" msgid ""
"The simple ``ProductionClass`` below has a ``closer`` method. If it is " "The simple ``ProductionClass`` below has a ``closer`` method. If it is "
"called with an object then it calls ``close`` on it." "called with an object then it calls ``close`` on it."
msgstr "" msgstr ""
"Ci-dessous, ``ProductionClass`` dispose d'une méthode ``closer``. Si on "
"l'appelle avec un objet, alors elle appelle la méthode ``close`` dessus."
#: ../Doc/library/unittest.mock-examples.rst:91 #: ../Doc/library/unittest.mock-examples.rst:91
msgid "" msgid ""
"So to test it we need to pass in an object with a ``close`` method and check " "So to test it we need to pass in an object with a ``close`` method and check "
"that it was called correctly." "that it was called correctly."
msgstr "" msgstr ""
"Ainsi, pour tester cette classe, nous devons lui passer un objet ayant une "
"méthode ``close``, puis vérifier qu'elle a bien été appelée."
#: ../Doc/library/unittest.mock-examples.rst:99 #: ../Doc/library/unittest.mock-examples.rst:99
msgid "" msgid ""
@ -102,10 +127,15 @@ msgid ""
"accessing it in the test will create it, but :meth:`~Mock." "accessing it in the test will create it, but :meth:`~Mock."
"assert_called_with` will raise a failure exception." "assert_called_with` will raise a failure exception."
msgstr "" msgstr ""
"En fait, nous n'avons pas à nous soucier de fournir la méthode ``close`` "
"dans notre objet « simulé ». Le simple fait d'accéder à la méthode ``close`` "
"l'a crée. Si par contre la méthode ``close`` n'a pas été appelée alors, bien "
"que le test la créée en y accédant, :meth:`~Mock.assert_called_with` lèvera "
"une exception."
#: ../Doc/library/unittest.mock-examples.rst:106 #: ../Doc/library/unittest.mock-examples.rst:106
msgid "Mocking Classes" msgid "Mocking Classes"
msgstr "" msgstr "Simulation des classes"
#: ../Doc/library/unittest.mock-examples.rst:108 #: ../Doc/library/unittest.mock-examples.rst:108
msgid "" msgid ""
@ -114,6 +144,11 @@ msgid ""
"Instances are created by *calling the class*. This means you access the " "Instances are created by *calling the class*. This means you access the "
"\"mock instance\" by looking at the return value of the mocked class." "\"mock instance\" by looking at the return value of the mocked class."
msgstr "" msgstr ""
"Un cas d'utilisation courant consiste à émuler les classes instanciées par "
"le code que nous testons. Quand on *patch* une classe, alors cette classe "
"est remplacée par un objet *mock*. Les instances de la classe étant créées "
"en *appelant la classe*, on accède à « l'instance *mock* » via la valeur de "
"retour de la classe émulée."
#: ../Doc/library/unittest.mock-examples.rst:113 #: ../Doc/library/unittest.mock-examples.rst:113
msgid "" msgid ""
@ -341,9 +376,8 @@ msgid ""
msgstr "" msgstr ""
#: ../Doc/library/unittest.mock-examples.rst:388 #: ../Doc/library/unittest.mock-examples.rst:388
#, fuzzy
msgid "``patch.object``::" msgid "``patch.object``::"
msgstr "``patch.object``:" msgstr "``patch.object`` ::"
#: ../Doc/library/unittest.mock-examples.rst:405 #: ../Doc/library/unittest.mock-examples.rst:405
msgid "" msgid ""