Package teardown fails to run in some cases when subpackage specified on command line

18 views
Skip to first unread message

Kevin Fitch

unread,
May 12, 2016, 3:36:55 PM5/12/16
to nose-users
I am using nose version 1.3.6 on python 2.7.10 on Linux. I have the following test directory layout:

parent/__init__.py:
def setup_package(): print "setup parent"
def teardown_package(): print "teardown parent"

parent/test.py:
#...

parent/child/__init__.py:
def setup_package(): print "setup child"; raise Exception("Failure!")
def teardown_package(): print "teardown child"

parent/child/test.py:
#...


If I run:
nosetests -s parent

I get exactly what I would expect:
setup parent
setup child
Eteardown parent
...

If instead I run
nosetests -s parent/child

It does not run the parent teardown. I get:
setup parent
setup child
E
...

If a setup succeeds I would expect the matching teardown to run. Am I missing something?

Kevin Fitch

John T

unread,
May 12, 2016, 10:49:39 PM5/12/16
to nose-...@googlegroups.com

I ran into the same issue a while ago. If the exception happens in setup_*() the corresponding teardown for that context is never executed. I had to hack a fix to make it work as I expected it.

--
You received this message because you are subscribed to the Google Groups "nose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nose-users+...@googlegroups.com.
To post to this group, send email to nose-...@googlegroups.com.
Visit this group at https://groups.google.com/group/nose-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages