summaryrefslogtreecommitdiff
path: root/tests/custom_methods
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-02-02 10:37:27 -0800
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-02-02 10:37:27 -0800
commit54bfa4caab11d364eb208ba6639836fa22d69a04 (patch)
treef24020307dd5b529989329bfabfc95effcecffe8 /tests/custom_methods
parentab2f21080d8b3112c1ba9a0bf923eae733be4242 (diff)
parent3ffeb931869cc68a8e0916219702ee282afc6e9d (diff)
Merge pull request #2154 from manfre/close-cursors
Fixed #21751 -- Explicitly closed cursors.
Diffstat (limited to 'tests/custom_methods')
-rw-r--r--tests/custom_methods/models.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/custom_methods/models.py b/tests/custom_methods/models.py
index cef3fd722b..78e00a99b8 100644
--- a/tests/custom_methods/models.py
+++ b/tests/custom_methods/models.py
@@ -30,11 +30,11 @@ class Article(models.Model):
database query for the sake of demonstration.
"""
from django.db import connection
- cursor = connection.cursor()
- cursor.execute("""
- SELECT id, headline, pub_date
- FROM custom_methods_article
- WHERE pub_date = %s
- AND id != %s""", [connection.ops.value_to_db_date(self.pub_date),
- self.id])
- return [self.__class__(*row) for row in cursor.fetchall()]
+ with connection.cursor() as cursor:
+ cursor.execute("""
+ SELECT id, headline, pub_date
+ FROM custom_methods_article
+ WHERE pub_date = %s
+ AND id != %s""", [connection.ops.value_to_db_date(self.pub_date),
+ self.id])
+ return [self.__class__(*row) for row in cursor.fetchall()]