Skip to content

Commit

Permalink
read-only flag and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nrhinehart committed Oct 3, 2015
1 parent 515cf6b commit d6cbbc0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ def build_with_bad_flag():
fname = norm_file('tests/db/sqlitedict-override-test.sqlite')
orig_db = sqlitedict.SqliteDict(filename=fname, flag = 'FOO')

try: build_with_bad_flag()
except RuntimeError as e:
self.assertTrue(e.message.find('Unrecognized flag') == 0)
with self.assertRaises(RuntimeError):
build_with_bad_flag()

def test_readonly(self):
fname = norm_file('tests/db/sqlitedict-override-test.sqlite')
Expand All @@ -104,9 +103,8 @@ def test_readonly(self):
def attempt_write():
readonly_db['key'] = ['new_value']

try: attempt_write()
except RuntimeError as e:
self.assertTrue(e.message.find('Refusing to write') == 0)
with self.assertRaises(RuntimeError):
attempt_write()

def test_overwrite_using_flag_w(self):
"""Re-opening of a database with flag='w' destroys only the target table."""
Expand Down

0 comments on commit d6cbbc0

Please sign in to comment.