mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-01 15:04:11 +02:00
feat(db): document and test Database.memory and Database.memory_name
Refs #590, closes #734
This commit is contained in:
parent
d2ac3765ed
commit
d302835d57
2 changed files with 39 additions and 0 deletions
|
|
@ -87,3 +87,34 @@ def test_legacy_transaction_control_connection_is_accepted(tmpdir):
|
|||
db["t"].insert({"id": 1}, pk="id")
|
||||
assert [r["id"] for r in db["t"].rows] == [1]
|
||||
db.close()
|
||||
|
||||
|
||||
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