Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Lib/test/test_regions/test_cown.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,27 @@ def other_thread():

# Cleanup
t2.join()

def test_release_fails_for_open_regions(self):
r = Region()
c = Cown(r)

# Releasing a cown with an open region should error
with self.assertRaises(RuntimeError):
c.release()

r = None

# This release should succeed, since `r` should be closed
c.release()

def test_release_cleans_region(self):
c = Cown(Region())
c.value._make_dirty()

self.assertTrue(c.value.is_dirty)

# Releasing the cown should clean the region first in an
# attempt to close it
with self.assertRaises(RuntimeError):
c.release()