Created
July 14, 2012 08:48
-
-
Save coolcodr/3110083 to your computer and use it in GitHub Desktop.
A Python decorator, @Assume, it will skip the test if the condition argument is False. It works similar to org.junit.Assume.assumeTrue().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nose.tools import nottest, istest | |
class assume(object): | |
def __init__(self, bool_condition): | |
self.bool_condition = bool_condition | |
def __call__(self, test_func): | |
if not self.bool_condition: | |
return nottest(test_func) | |
else: | |
return istest(test_func) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from django.conf import settings | |
class IntegrationTest(unittest.TestCase): | |
@assume(hasattr(settings, 'INTEGRATION_TEST_ENABLED') and settings.INTEGRATION_TEST_ENABLED) | |
def test_something(self): | |
# dome some tests here | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment