#6345 defect closed duplicate (duplicate)

trial can't run stdlib unittest test methods with expected failures

Reported by: exarkun Owned by:
Priority: normal Milestone:
Component: trial Keywords:
Cc: jml Branch:
Author: Launchpad Bug:

Description

From the Python stdlib unittest module documentation:

import unittest

class ExpectedFailureTestCase(unittest.TestCase):
    @unittest.expectedFailure
    def test_fail(self):
        self.assertEqual(1, 0, "broken")

trial should be able to run this, but instead it fails with an unhandled exception:

$ trial test_xfail.py 
test_xfail
  ExpectedFailureTestCase
    test_fail ... Traceback (most recent call last):
  File "/usr/bin/trial", line 18, in <module>
    run()
  File "/usr/lib/python2.7/dist-packages/twisted/scripts/trial.py", line 382, in run
    test_result = trialRunner.run(suite)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 809, in run
    return self._runWithoutDecoration(test)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 838, in _runWithoutDecoration
    run()
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 833, in <lambda>
    run = lambda: suite.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 284, in run
    TestSuite.run(self, result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1413, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1401, in __call__
    return self.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 179, in run
    super(LoggedSuite, self).run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1413, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1401, in __call__
    return self.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 152, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1401, in __call__
    return self.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 152, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1401, in __call__
    return self.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 152, in run
    test(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1436, in __call__
    return self.run(result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 1446, in run
    reporter._AdaptedReporter(result, self.__class__))
  File "/usr/lib/python2.7/unittest/case.py", line 335, in run
    addExpectedFailure(self, e.exc_info)
TypeError: addExpectedFailure() takes exactly 4 arguments (3 given)

This is probably because trial's addExpectedFailure TestResult API is incompatible with that of the standard library.

Change History (3)

comment:1 Changed 19 months ago by DefaultCC Plugin

  • Cc jml added

comment:2 Changed 17 months ago by Julian

#1706 was closed as being similar-y to this.

comment:3 Changed 17 months ago by Julian

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #4811

Note: See TracTickets for help on using tickets.