From 66804e99fced8016a425be9169b71fae7e28e403 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 30 Mar 2026 12:55:54 -0700 Subject: [PATCH] fix(python): use correct exception types in namespace tests (#3206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Namespace tests expected `RuntimeError` for table-not-found and namespace-not-empty cases, but `lance_namespace` raises `TableNotFoundError` and `NamespaceNotEmptyError` which inherit from `Exception`, not `RuntimeError`. - Updated `pytest.raises` to use the correct exception types. ## Test plan - [x] CI passes on `test_namespace.py` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) --- python/python/tests/test_namespace.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/python/tests/test_namespace.py b/python/python/tests/test_namespace.py index 70bc046ba..4bd0a5dd5 100644 --- a/python/python/tests/test_namespace.py +++ b/python/python/tests/test_namespace.py @@ -8,6 +8,7 @@ import shutil import pytest import pyarrow as pa import lancedb +from lance_namespace.errors import NamespaceNotEmptyError, TableNotFoundError class TestNamespaceConnection: @@ -130,7 +131,7 @@ class TestNamespaceConnection: assert len(list(db.table_names(namespace=["test_ns"]))) == 0 # Should not be able to open dropped table - with pytest.raises(RuntimeError): + with pytest.raises(TableNotFoundError): db.open_table("table1", namespace=["test_ns"]) def test_create_table_with_schema(self): @@ -340,7 +341,7 @@ class TestNamespaceConnection: db.create_table("test_table", schema=schema, namespace=["test_namespace"]) # Try to drop namespace with tables - should fail - with pytest.raises(RuntimeError, match="is not empty"): + with pytest.raises(NamespaceNotEmptyError): db.drop_namespace(["test_namespace"]) # Drop table first