pombreda / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

Nose doesn't honor the decorator 'unittest.expectedFailure' #428

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create a unit test method and decorate with the 'decorator'
   unittest.expectedFailure (introduced in Python 2.7)

2. Run the above test using 'nosetests <test_module.py>'

3.The warning message 'RuntimeWarning: TestResult has no
  addExpectedFailure method, reporting as passes RuntimeWarning)' is
  reported on the console is printed

What is the expected output? What do you see instead?

When the unit test modules that has the unittests adorned with the
decorator 'unittest.expectedFailure' are invoked using 'python
<test_module>.py' no warnings are printed to console. But the
invocation of same test module using nose (i.e. 'nosetests
<test_module.py>') prints a RunTimeWarning above reported.

What version of the product are you using? On what operating system?

$ nosetests -V
nosetests-script.py version 1.0.0
OS: Windows XP SP3
Python version : 2.7

Please provide any additional information below.

Here are the detailed steps to simulate the problem scenario.

Consider a dummy class
%cat report.py

class Hello(object):

    def value(self):
        return 100

And the associated unittest module
(Both reside in same directory)

%cat report_tests.py

import unittest
from report import Hello

class TestReport(unittest.TestCase):

    @unittest.expectedFailure
    def test_value(self):
        h = Hello()
        self.assertEqual(10,h.value())

if __name__ == '__main__':
    unittest.main()

%nosetests -V
nosetests-script.py version 1.0.0

% nosetests report_tests.py
C:\Python27\lib\unittest\case.py:327: RuntimeWarning: TestResult has no 
addExpectedFailure method, reporting as passes
  RuntimeWarning)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

%python -V
Python 2.7

%python report_tests.py
x
--------------------------------------------------------
Ran 1 test in 0.000s

OK (expected failures=1)

As the above steps indicate the test invocation doesn't thrown any
warning when launched using python but shows a warning message when
launched using nosetests.

Original issue reported on code.google.com by sateeshp...@gmail.com on 14 Jun 2011 at 8:42

GoogleCodeExporter commented 9 years ago
Here is a patch that adds a plugin along the lines of nose.plugins.skip for 
handling Python 2.7's expected failures. It needs some work and unit tests, but 
it's functional.

Original comment by robert.kern@gmail.com on 10 Nov 2011 at 11:17

Attachments: