|
@@ -19,14 +19,71 @@ from .views import empty_response
|
|
|
|
|
|
|
|
|
class SkippingTestCase(TestCase):
|
|
|
+ def _assert_skipping(self, func, expected_exc):
|
|
|
+
|
|
|
+ try:
|
|
|
+ func()
|
|
|
+ except expected_exc:
|
|
|
+ pass
|
|
|
+ except Exception as e:
|
|
|
+ self.fail("No %s exception should have been raised for %s." % (
|
|
|
+ e.__class__.__name__, func.__name__))
|
|
|
+
|
|
|
def test_skip_unless_db_feature(self):
|
|
|
- "A test that might be skipped is actually called."
|
|
|
+ """
|
|
|
+ Testing the django.test.skipUnlessDBFeature decorator.
|
|
|
+ """
|
|
|
|
|
|
@skipUnlessDBFeature("__class__")
|
|
|
def test_func():
|
|
|
raise ValueError
|
|
|
|
|
|
- self.assertRaises(ValueError, test_func)
|
|
|
+ @skipUnlessDBFeature("notprovided")
|
|
|
+ def test_func2():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipUnlessDBFeature("__class__", "__class__")
|
|
|
+ def test_func3():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipUnlessDBFeature("__class__", "notprovided")
|
|
|
+ def test_func4():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ self._assert_skipping(test_func, ValueError)
|
|
|
+ self._assert_skipping(test_func2, unittest.SkipTest)
|
|
|
+ self._assert_skipping(test_func3, ValueError)
|
|
|
+ self._assert_skipping(test_func4, unittest.SkipTest)
|
|
|
+
|
|
|
+ def test_skip_if_db_feature(self):
|
|
|
+ """
|
|
|
+ Testing the django.test.skipIfDBFeature decorator.
|
|
|
+ """
|
|
|
+ @skipIfDBFeature("__class__")
|
|
|
+ def test_func():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipIfDBFeature("notprovided")
|
|
|
+ def test_func2():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipIfDBFeature("__class__", "__class__")
|
|
|
+ def test_func3():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipIfDBFeature("__class__", "notprovided")
|
|
|
+ def test_func4():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ @skipIfDBFeature("notprovided", "notprovided")
|
|
|
+ def test_func5():
|
|
|
+ raise ValueError
|
|
|
+
|
|
|
+ self._assert_skipping(test_func, unittest.SkipTest)
|
|
|
+ self._assert_skipping(test_func2, ValueError)
|
|
|
+ self._assert_skipping(test_func3, unittest.SkipTest)
|
|
|
+ self._assert_skipping(test_func4, unittest.SkipTest)
|
|
|
+ self._assert_skipping(test_func5, ValueError)
|
|
|
|
|
|
|
|
|
class SkippingClassTestCase(TestCase):
|