@@ -116,3 +116,40 @@ def test_command_extract(self):
116116 diffed = runner .invoke (extract , ['root[2][2]' , path ])
117117 assert 0 == diffed .exit_code
118118 assert '0.288\n ' == diffed .output
119+
120+
121+ class TestCliEntryPoint :
122+ """Tests for the ``deep`` console-script wrapper (deepdiff/cli.py)."""
123+
124+ def test_main_runs_cli_when_click_available (self ):
125+ # click is available in the test environment; invoking the entry point
126+ # with --help should print the group help and exit cleanly.
127+ from click .testing import CliRunner
128+
129+ from deepdiff .commands import cli
130+
131+ result = CliRunner ().invoke (cli , ['--help' ])
132+ assert result .exit_code == 0
133+ assert 'command line tool' in result .output
134+
135+ def test_main_reports_missing_click_dependency (self , monkeypatch ):
136+ # Simulate a default install without the optional ``cli`` extra: the
137+ # entry point must fail with an actionable message rather than a bare
138+ # ModuleNotFoundError traceback. See issue #594.
139+ import builtins
140+
141+ from deepdiff import cli as cli_entry
142+
143+ real_import = builtins .__import__
144+
145+ def fake_import (name , * args , ** kwargs ):
146+ if name == 'click' :
147+ raise ImportError ("No module named 'click'" )
148+ return real_import (name , * args , ** kwargs )
149+
150+ monkeypatch .setattr (builtins , '__import__' , fake_import )
151+
152+ with pytest .raises (SystemExit ) as exc_info :
153+ cli_entry .main ()
154+
155+ assert 'pip install deepdiff[cli]' in str (exc_info .value )
0 commit comments