diff --git a/tests/test_doctor.py b/tests/test_doctor.py index 6a5b46a7..0cccd370 100644 --- a/tests/test_doctor.py +++ b/tests/test_doctor.py @@ -77,6 +77,15 @@ def _run_doctor(workspace=None, fix=False, verbose=False, fmt="json"): args.verbose = verbose args.format = fmt args.workspace = workspace + # Issue #195 added a --check dispatch to doctor.execute(): when + # getattr(args, "check", None) is truthy, execution goes through + # _dispatch_subcommands() instead of the normal full-checks path. + # MagicMock auto-vivifies any attribute access (args.check returns a + # fresh MagicMock, not None), so without this explicit assignment every + # test using this helper silently exercised the wrong code path and got + # the umbrella {s, st, r} shape instead of doctor's own + # {status, exit_code, checks, ...} shape. + args.check = None return doctor_module.execute(args, workspace or "") @@ -346,6 +355,7 @@ def test_fix_calls_pip_when_deps_missing(self, tmp_path): args.verbose = False args.format = "json" args.workspace = str(tmp_path) + args.check = None # see _run_doctor() docstring result = doctor_module.execute(args, str(tmp_path)) assert mock_run.called @@ -372,6 +382,7 @@ def test_fix_noop_when_nothing_fixable(self, tmp_path): args.verbose = False args.format = "json" args.workspace = str(tmp_path) + args.check = None # see _run_doctor() docstring result = doctor_module.execute(args, str(tmp_path)) # pip should NOT have been called.