(tmp_dir, dvc, mocker, capsys, plots_data, auto_open)
| 142 | |
| 143 | @pytest.mark.parametrize("auto_open", [True, False]) |
| 144 | def 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 | |
| 169 | def test_plots_diff_open_wsl(tmp_dir, dvc, mocker, plots_data): |
nothing calls this directly
no test coverage detected