test.skipUnlessDBFeature()

skipUnlessDBFeature(*feature_name_strings) [source]

Skip the decorated test or TestCase if any of the named database features are not supported.

For example, the following test will only be executed if the database supports transactions (e.g., it would run under PostgreSQL, but not under MySQL with MyISAM tables):

class MyTests(TestCase):
    @skipUnlessDBFeature('supports_transactions')
    def test_transaction_behavior(self):
        # ... conditional test code
        pass
doc_Django
2016-10-09 18:40:08
Comments
Leave a Comment

Please login to continue.