nose-devs/nose — Issue #337: tearDown is not called
Author: jpellerin
Created: 2011-12-14 16:08:17+00:00
State: closed

I have a simple test class as follows:

class TestNose(object):

def setUp(self):
print "setup"

def tearDown(self):
print "teardown"

def test_test(self):
print "in test_test"
assert False
print "after assert"

When I run the tests, "teardown" is not printed in the output:

======================================================================
FAIL: test_nose.TestNose.test_test
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/lib/python-support/python2.6/nose/case.py", line 182, in runTest
self.test(*self.arg)
File "/home/jon/Projects/wordbook/tests/test_nose.py", line 29, in test_test
assert False
AssertionError:
-------------------- >> begin captured stdout << ---------------------
setup
in test_test

--------------------- >> end captured stdout << ----------------------

----------------------------------------------------------------------
Ran 1 test in 0.013s

FAILED (failures=1)

This leads me to believe tearDown is not being called. Indeed, when I run
it with --debug=nose, there are some messages that support this (although
I'm not 100% sure that is what they mean):

nose.suite: DEBUG: ancestor may need setup
nose.suite: DEBUG: ancestor may need setup
nose.suite: DEBUG: ancestor does need setup
nose.suite: DEBUG: setup context

nose.suite: DEBUG: completed suite setup
nose.suite: DEBUG: precache is [test_nose.TestNose.test_test]
nose: DEBUG: call fixture .setup
Fnose: DEBUG: call fixture .teardown
nose.suite: DEBUG: context teardown
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: setup
ancestor
nose.suite: DEBUG: teardown
context
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: setup
ancestor
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: ancestor already torn down
nose.suite: DEBUG: context teardown
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: setup
ancestor
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: setup
ancestor
nose.suite: DEBUG: context teardown
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: setup
ancestor
nose.suite: DEBUG: teardown
context
nose.suite: DEBUG: ancestor may need teardown
nose.suite: DEBUG: ancestor already torn down

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

I expect to see "teardown" printed in the output.

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

nosetests version 0.11.1
Ubuntu Jaunty
Python 2.6.2

Google Code Info:
Issue #: 274
Author: juan.bl...@gmail.com
Created On: 2009-06-27T09:31:02.000Z
Closed On: 2009-06-27T13:03:01.000Z