-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bind manual database close methods to Python APIs (#3435)
* Bind manual database close methods to Python APIs * Add new line * Run clang-format * Fix linter --------- Co-authored-by: CI Bot <mewim@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import kuzu | ||
import pytest | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def test_connection_close(tmp_path: Path, build_dir: Path) -> None: | ||
db_path = tmp_path / "test_connection_close.kuzu" | ||
db = kuzu.Database(database_path=db_path, read_only=False) | ||
conn = kuzu.Connection(db) | ||
conn.close() | ||
assert conn.is_closed | ||
pytest.raises(RuntimeError, conn.execute, "RETURN 1") | ||
db.close() | ||
|
||
|
||
def test_connection_close_context_manager(tmp_path: Path, build_dir: Path) -> None: | ||
db_path = tmp_path / "test_connection_close_context_manager.kuzu" | ||
with kuzu.Database(database_path=db_path, read_only=False) as db: | ||
with kuzu.Connection(db) as conn: | ||
pass | ||
assert conn.is_closed | ||
pytest.raises(RuntimeError, conn.execute, "RETURN 1") | ||
assert db.is_closed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters