Skip to content

Commit

Permalink
Fixed "connection already closed" error in django 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jun 7, 2015
1 parent 1e0a7cd commit ba5a722
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/django_hstore_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,11 +1640,16 @@ class SchemaDataBag(models.Model):


class TestNotTransactional(SimpleTestCase):
if DJANGO_VERSION[:2] >= (1, 8):
def setUp(self):
# avoid error "connection already closed"
connection.connect()

if DJANGO_VERSION[:2] >= (1, 6):
def test_hstore_registring_in_transaction_block(self):
obj1 = DataBag.objects.create(name='alpha1', data={'v': '1', 'v2': '3'})
obj2 = DataBag.objects.create(name='alpha2', data={'v': '1', 'v2': '3'})
# Close any existing connection previously do anything
# Close any existing connection before doing anything
connection.close()
with transaction.atomic():
qs = DataBag.objects.filter(name__in=["alpha2", "alpha1"])
Expand All @@ -1656,7 +1661,7 @@ def test_hstore_registring_in_transaction_block(self):
def test_hstore_registring_in_transaction_block(self):
obj1 = DataBag.objects.create(name='alpha1', data={'v': '1', 'v2': '3'})
obj2 = DataBag.objects.create(name='alpha2', data={'v': '1', 'v2': '3'})
# Close any existing connection previously do anything
# Close any existing connection before doing anything
connection.close()
with transaction.commit_on_success():
qs = DataBag.objects.filter(name__in=["alpha2", "alpha1"])
Expand Down

0 comments on commit ba5a722

Please sign in to comment.