Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyiceberg/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def run(
else:
ctx.obj["output"] = JsonOutput(verbose=verbose)

if ctx.invoked_subcommand == "version":
return

try:
ctx.obj["catalog"] = load_catalog(catalog, **properties)
except Exception as e:
Expand Down
12 changes: 12 additions & 0 deletions tests/cli/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from click.testing import CliRunner
from pytest_mock import MockFixture

from pyiceberg import __version__
from pyiceberg.catalog.memory import InMemoryCatalog
from pyiceberg.cli.console import run
from pyiceberg.io import WAREHOUSE
Expand Down Expand Up @@ -61,6 +62,17 @@ def test_hive_catalog_missing_uri_shows_helpful_error(mocker: MockFixture) -> No
assert "'uri'" not in result.output


def test_version_does_not_load_catalog(mocker: MockFixture) -> None:
mock_load_catalog = mocker.patch("pyiceberg.cli.console.load_catalog", side_effect=Exception("should not be called"))

runner = CliRunner()
result = runner.invoke(run, ["version"])

assert result.exit_code == 0
assert result.output == f"{__version__}\n"
mock_load_catalog.assert_not_called()


@pytest.fixture(autouse=True)
def env_vars(mocker: MockFixture) -> None:
mocker.patch.dict(os.environ, MOCK_ENVIRONMENT)
Expand Down
Loading