mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-01 23:14:12 +02:00
feat(db): document and test Database.memory and Database.memory_name
Refs #590
This commit is contained in:
parent
8d74ffc932
commit
36a34e95bf
2 changed files with 39 additions and 0 deletions
|
|
@ -39,3 +39,34 @@ def test_database_close(tmpdir, memory):
|
|||
db.close()
|
||||
with pytest.raises(sqlite3.ProgrammingError):
|
||||
db.execute("select 1 + 1")
|
||||
|
||||
|
||||
def test_memory_attribute_for_memory_true():
|
||||
db = Database(memory=True)
|
||||
assert db.memory is True
|
||||
assert db.memory_name is None
|
||||
|
||||
|
||||
def test_memory_attribute_for_memory_name():
|
||||
db = Database(memory_name="shared_attr")
|
||||
assert db.memory is True
|
||||
assert db.memory_name == "shared_attr"
|
||||
|
||||
|
||||
def test_memory_attribute_for_memory_string_path():
|
||||
db = Database(":memory:")
|
||||
assert db.memory is True
|
||||
assert db.memory_name is None
|
||||
|
||||
|
||||
def test_memory_attribute_for_file_path(tmpdir):
|
||||
db = Database(str(tmpdir / "file.db"))
|
||||
assert db.memory is False
|
||||
assert db.memory_name is None
|
||||
|
||||
|
||||
def test_memory_attribute_for_existing_connection():
|
||||
conn = sqlite3.connect(":memory:")
|
||||
db = Database(conn)
|
||||
assert db.memory is False
|
||||
assert db.memory_name is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue