File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ def run(
101101 else :
102102 ctx .obj ["output" ] = JsonOutput (verbose = verbose )
103103
104+ if ctx .invoked_subcommand == "version" :
105+ return
106+
104107 try :
105108 ctx .obj ["catalog" ] = load_catalog (catalog , ** properties )
106109 except Exception as e :
Original file line number Diff line number Diff line change 2525from click .testing import CliRunner
2626from pytest_mock import MockFixture
2727
28+ from pyiceberg import __version__
2829from pyiceberg .catalog .memory import InMemoryCatalog
2930from pyiceberg .cli .console import run
3031from pyiceberg .io import WAREHOUSE
@@ -61,6 +62,17 @@ def test_hive_catalog_missing_uri_shows_helpful_error(mocker: MockFixture) -> No
6162 assert "'uri'" not in result .output
6263
6364
65+ def test_version_does_not_load_catalog (mocker : MockFixture ) -> None :
66+ mock_load_catalog = mocker .patch ("pyiceberg.cli.console.load_catalog" , side_effect = Exception ("should not be called" ))
67+
68+ runner = CliRunner ()
69+ result = runner .invoke (run , ["version" ])
70+
71+ assert result .exit_code == 0
72+ assert result .output == f"{ __version__ } \n "
73+ mock_load_catalog .assert_not_called ()
74+
75+
6476@pytest .fixture (autouse = True )
6577def env_vars (mocker : MockFixture ) -> None :
6678 mocker .patch .dict (os .environ , MOCK_ENVIRONMENT )
You can’t perform that action at this time.
0 commit comments