@@ -2744,6 +2744,10 @@ msgid ""
27442744"method will only be called if the :meth:`asyncSetUp` succeeds, regardless of"
27452745" the outcome of the test method. The default implementation does nothing."
27462746msgstr ""
2747+ "在测试方法被调用并记录结果之后立即被调用的方法。 此方法会在 :meth:`~TestCase.tearDown` 之前被调用。 "
2748+ "即使在测试方法引发异常时它仍会被调用,因此子类中的实现将需要特别注意检查内部状态。 除 :exc:`AssertionError` 或 "
2749+ ":exc:`SkipTest` 外,此方法所引发的任何异常都将被视为额外的错误而非测试失败(因而会增加总计错误报告数)。 此方法将只有 "
2750+ ":meth:`asyncSetUp` 成功执行时被调用,无论测试方法的结果如何。 默认的实现将不做任何事情。"
27472751
27482752#: ../../library/unittest.rst:1662
27492753msgid ""
@@ -2770,6 +2774,9 @@ msgid ""
27702774"returned to :meth:`run`'s caller. At the end of the test all the tasks in "
27712775"the event loop are cancelled."
27722776msgstr ""
2777+ "设置一个新的事件循环来运行测试,将结果收集至作为 *result* 传入的 :class:`TestResult` 对象中。 如果 *result* "
2778+ "被省略或为 ``None``,则会创建一个临时的结果对象(通过调用 :meth:`~TestCase.defaultTestResult` "
2779+ "方法)并使用它。 结果对象会被返回给 :meth:`run` 的调用方。 在测试结束时事件循环中的所有任务都将被取消。"
27732780
27742781#: ../../library/unittest.rst:1685
27752782msgid "An example illustrating the order::"
@@ -2955,6 +2962,11 @@ msgid ""
29552962"tests returned by this method unless the caller uses a subclass that "
29562963"overrides :meth:`!TestSuite._removeTestAtIndex` to preserve test references."
29572964msgstr ""
2965+ "由 :class:`TestSuite` 分组的测试总是可以通过迭代来访问。 其子类可以通过重写 :meth:`!__iter__` 来惰性地提供测试。"
2966+ " 请注意此方法可在单个套件上多次被调用(例如在对测试计数或比较相等性时)因此在. :meth:`TestSuite.run` "
2967+ "之前重复迭代所返回的测试对于每次调用迭代都必须相同。 在 :meth:`TestSuite.run` "
2968+ "之后,调用方不应继续访问此方法所返回的测试,除非调用方使用重写了 :meth:`!TestSuite._removeTestAtIndex` "
2969+ "的子类来保留对测试的引用。to preserve test references."
29582970
29592971#: ../../library/unittest.rst:1804
29602972msgid ""
@@ -2971,13 +2983,18 @@ msgid ""
29712983":class:`TestCase` after :meth:`TestSuite.run`. Subclasses can restore that "
29722984"behavior by overriding :meth:`!TestSuite._removeTestAtIndex`."
29732985msgstr ""
2986+ "在较早的版本中 :class:`TestSuite` 会在 :meth:`TestSuite.run` 之后保留对每个 "
2987+ ":class:`TestCase` 的引用。 其子类可以通过重写 :meth:`!TestSuite._removeTestAtIndex` "
2988+ "来恢复此行为。"
29742989
29752990#: ../../library/unittest.rst:1814
29762991msgid ""
29772992"In the typical usage of a :class:`TestSuite` object, the :meth:`run` method "
29782993"is invoked by a :class:`!TestRunner` rather than by the end-user test "
29792994"harness."
29802995msgstr ""
2996+ "在 :class:`TestSuite` 对象的典型应用中,:meth:`run` 方法是由 :class:`!TestRunner` "
2997+ "唤起而不是由最终用户测试来控制的。"
29812998
29822999#: ../../library/unittest.rst:1819
29833000msgid "Loading and running tests"
@@ -3017,7 +3034,7 @@ msgstr ":class:`TestLoader` 对象具有下列方法:"
30173034msgid ""
30183035"Return a suite of all test cases contained in the :class:`TestCase`\\ "
30193036"-derived :class:`!testCaseClass`."
3020- msgstr ""
3037+ msgstr "返回一个包含在 :class:`TestCase` 所派生的 :class:`!testCaseClass` 中的所有测试用例的测试套件。 "
30213038
30223039#: ../../library/unittest.rst:1851
30233040msgid ""
@@ -3027,6 +3044,9 @@ msgid ""
30273044":meth:`!runTest` method is implemented, a single test case is created for "
30283045"that method instead."
30293046msgstr ""
3047+ "测试用例实例将针对由 :meth:`getTestCaseNames` 所指定的每个方法进行创建。 在默认情况下这些方法名称将以 ``test`` "
3048+ "开头。 如果 :meth:`getTestCaseNames` 不返回任何方法,但 :meth:`!runTest` "
3049+ "方法已被实现,则会为该方法创建一个单独的测试用例。"
30303050
30313051#: ../../library/unittest.rst:1860
30323052msgid ""
@@ -3103,6 +3123,11 @@ msgid ""
31033123"can refer to modules and packages which have not been imported; they will be"
31043124" imported as a side-effect."
31053125msgstr ""
3126+ "举例来说,如果你有一个模块 :mod:`!SampleTests` 其中包含一个派生自 :class:`TestCase` 的类 "
3127+ ":class:`!SampleTestCase`,它带有三个测试方法 (:meth:`!test_one`, :meth:`!test_two` 和 "
3128+ ":meth:`!test_three`),则指定 ``'SampleTests.SampleTestCase'`` "
3129+ "将使此方法返回一个将运行全部三个测试方法的测试套件。 指定 ``'SampleTests.SampleTestCase.test_two'`` "
3130+ "将使它返回一个仅运行 :meth:`!test_two` 测试方法的测试套件。 可以指定尚未被导入的模块和包;它们将作为附带影响被导入。"
31063131
31073132#: ../../library/unittest.rst:1911
31083133msgid "The method optionally resolves *name* relative to the given *module*."
@@ -3317,6 +3342,8 @@ msgid ""
33173342" purposes; a :class:`TestResult` instance is returned by the "
33183343":meth:`!TestRunner.run` method for this purpose."
33193344msgstr ""
3345+ "建立在 :mod:`unittest` 之上的测试框架可能会想要访问通过一组测试所产生的 :class:`TestResult` "
3346+ "对象用于报告信息;:class:`TestResult` 实例是由 :meth:`!TestRunner.run` 方法出于这个目的而返回的。"
33203347
33213348#: ../../library/unittest.rst:2056
33223349msgid ""
@@ -3420,6 +3447,8 @@ msgid ""
34203447":class:`!TestRunner` objects should respect this flag and return without "
34213448"running any additional tests."
34223449msgstr ""
3450+ "此方法可被调用以提示正在运行的测试集要将 :attr:`shouldStop` 属性设为 ``True`` 来表示其应当被中止。 "
3451+ ":class:`!TestRunner` 对象应当遵守此旗标并返回而不再运行任何额外的测试。"
34233452
34243453#: ../../library/unittest.rst:2143
34253454msgid ""
0 commit comments