I have observed this same behavior, that unittest.skip, unittest.skipIf, etc. decorators are not respected when using nose to run my tests.
Bakuriu's suggestion to write a decorator which raises a SkipTest exception in the setUpClass method fixes the problem: tests are now properly skipped whether running from unittest.main or from nose.
Here is code, heavily based on the unittest decorator source code. The key lines are the ones for when the decorator is used on a TestCase class:
from unittest import SkipTest, TestCase
import functools
import types
def _id(obj):
return obj
def skip(reason):
"""Unconditionally skip a test."""
def decorator(test_item):
if not isinstance(test_item, (type, types.ClassType)):
@functools.wraps(test_item)
def skip_wrapper(*args, **kwargs):
raise SkipTest(reason)
test_item = skip_wrapper
elif issubclass(test_item, TestCase):
@classmethod
@functools.wraps(test_item.setUpClass)
def skip_wrapper(*args, **kwargs):
raise SkipTest(reason)
test_item.setUpClass = skip_wrapper
test_item.__unittest_skip__ = True
test_item.__unittest_skip_why__ = reason
return test_item
return decorator
def skipIf(condition, reason):
"""Skip a test if the condition is true."""
if condition:
return skip(reason)
return _id