Skip to content

Commit

Permalink
Removed Session.__del__ and added harsh deletion test
Browse files Browse the repository at this point in the history
  • Loading branch information
technige committed Mar 18, 2016
1 parent 126060f commit f1350ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 0 additions & 7 deletions neo4j/v1/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,6 @@ def __init__(self, driver):
self.transaction = None
self.last_result = None

def __del__(self):
try:
if not self.connection.closed:
self.connection.close()
except AttributeError:
pass

def __enter__(self):
return self

Expand Down
10 changes: 10 additions & 0 deletions test/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,16 @@ def test_can_consume_result_after_session_reuse(self):
assert [record[0] for record in result_a] == [1, 2, 3]
assert [record[0] for record in result_b] == [4, 5, 6]

def test_can_consume_results_after_harsh_session_death(self):
session = self.driver.session()
result_a = session.run("UNWIND range(1, 3) AS n RETURN n")
del session
session = self.driver.session()
result_b = session.run("UNWIND range(4, 6) AS n RETURN n")
del session
assert [record[0] for record in result_a] == [1, 2, 3]
assert [record[0] for record in result_b] == [4, 5, 6]

def test_can_consume_result_after_session_with_error(self):
session = self.driver.session()
with self.assertRaises(CypherError):
Expand Down

0 comments on commit f1350ad

Please sign in to comment.