MCPcopy
hub / github.com/treeverse/dvc / test_plots_diff_open

Function test_plots_diff_open

tests/unit/command/test_plots.py:144–166  ·  view source on GitHub ↗
(tmp_dir, dvc, mocker, capsys, plots_data, auto_open)

Source from the content-addressed store, hash-verified

142
143@pytest.mark.parametrize("auto_open", [True, False])
144def test_plots_diff_open(tmp_dir, dvc, mocker, capsys, plots_data, auto_open):
145 mocked_open = mocker.patch("webbrowser.open", return_value=True)
146
147 args = ["plots", "diff", "--targets", "plots.csv"]
148
149 if auto_open:
150 with dvc.config.edit() as conf:
151 conf["plots"]["auto_open"] = True
152 else:
153 args.append("--open")
154
155 cli_args = parse_args(args)
156 cmd = cli_args.func(cli_args)
157 mocker.patch("dvc.repo.plots.diff.diff", return_value=plots_data)
158
159 index_path = tmp_dir / "dvc_plots" / "index.html"
160 mocker.patch("dvc_render.render_html", return_value=index_path)
161
162 assert cmd.run() == 0
163 mocked_open.assert_called_once_with(index_path.as_uri())
164
165 out, _ = capsys.readouterr()
166 assert index_path.as_uri() in out
167
168
169def test_plots_diff_open_wsl(tmp_dir, dvc, mocker, plots_data):

Callers

nothing calls this directly

Calls 5

parse_argsFunction · 0.90
editMethod · 0.80
appendMethod · 0.80
funcMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected