Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure that assertNumQueries doesn't swallow exceptions inside the fu…

…nction.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14405 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6824c9b7962a04ba03d846a8dbe2507d166672a6 1 parent 429473a
@alex alex authored
View
5 django/test/testcases.py
@@ -524,7 +524,10 @@ def assertNumQueries(self, num, func=None, *args, **kwargs):
context.__enter__()
try:
func(*args, **kwargs)
- finally:
+ except:
+ context.__exit__(*sys.exc_info())
+ raise
+ else:
context.__exit__(*sys.exc_info())
def connections_support_transactions():
View
8 tests/regressiontests/test_utils/tests.py
@@ -8,6 +8,14 @@
class SkippingTestCase(TestCase):
+ def test_assert_num_queries(self):
+ def test_func():
+ raise ValueError
+
+ self.assertRaises(ValueError,
+ self.assertNumQueries, 2, test_func
+ )
+
def test_skip_unless_db_feature(self):
"A test that might be skipped is actually called."
# Total hack, but it works, just want an attribute that's always true.

0 comments on commit 6824c9b

Please sign in to comment.
Something went wrong with that request. Please try again.