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"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-09 17:54+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2019-12-01 23:32+0100\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"X-Generator: Poedit 2.2.1\n"
#: ../Doc/library/unittest.mock-examples.rst:2
msgid ":mod:`unittest.mock` --- getting started"
@ -20,35 +21,40 @@ msgstr ""
#: ../Doc/library/unittest.mock-examples.rst:27
msgid "Using Mock"
msgstr ""
msgstr "Utilisation de Mock ou l'art de singer"
#: ../Doc/library/unittest.mock-examples.rst:30
msgid "Mock Patching Methods"
msgstr ""
msgstr "Simulation des méthodes"
#: ../Doc/library/unittest.mock-examples.rst:32
msgid "Common uses for :class:`Mock` objects include:"
msgstr ""
msgstr "Usages courant de :class:`Mock` :"
#: ../Doc/library/unittest.mock-examples.rst:34
msgid "Patching methods"
msgstr ""
msgstr "Substitution des méthodes"
#: ../Doc/library/unittest.mock-examples.rst:35
msgid "Recording method calls on objects"
msgstr ""
msgstr "Enregistrement des appels faits sur les objets"
#: ../Doc/library/unittest.mock-examples.rst:37
msgid ""
"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:"
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
msgid ""
"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."
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
msgid ""
@ -56,6 +62,10 @@ msgid ""
"are interchangeable. As the ``MagicMock`` is the more capable class it makes "
"a sensible one to use by default."
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
msgid ""
@ -64,16 +74,22 @@ msgid ""
"or :meth:`~Mock.assert_called_once_with` method to check that it was called "
"with the correct arguments."
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
msgid ""
"This example tests that calling ``ProductionClass().method`` results in a "
"call to the ``something`` method:"
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
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
msgid ""
@ -82,18 +98,27 @@ msgid ""
"method (or some part of the system under test) and then check that it is "
"used in the correct way."
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
msgid ""
"The simple ``ProductionClass`` below has a ``closer`` method. If it is "
"called with an object then it calls ``close`` on it."
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
msgid ""
"So to test it we need to pass in an object with a ``close`` method and check "
"that it was called correctly."
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
msgid ""
@ -102,10 +127,15 @@ msgid ""
"accessing it in the test will create it, but :meth:`~Mock."
"assert_called_with` will raise a failure exception."
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
msgid "Mocking Classes"
msgstr ""
msgstr "Simulation des classes"
#: ../Doc/library/unittest.mock-examples.rst:108
msgid ""
@ -114,6 +144,11 @@ msgid ""
"Instances are created by *calling the class*. This means you access the "
"\"mock instance\" by looking at the return value of the mocked class."
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
msgid ""
@ -341,9 +376,8 @@ msgid ""
msgstr ""
#: ../Doc/library/unittest.mock-examples.rst:388
#, fuzzy
msgid "``patch.object``::"
msgstr "``patch.object``:"
msgstr "``patch.object`` ::"
#: ../Doc/library/unittest.mock-examples.rst:405
msgid ""