From b02855fb9389bfa7d35c2d164a8e1fe07bc53cd1 Mon Sep 17 00:00:00 2001 From: David de la Iglesia Castro Date: Wed, 23 Nov 2022 10:57:57 +0100 Subject: [PATCH] ui: Fix WSL check in `open_browser` (#8604) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ui: Fix WSL check in `open_browser` * Update dvc/ui/__init__.py Co-authored-by: Peter Rowlands (변기호) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Peter Rowlands (변기호) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- dvc/ui/__init__.py | 4 +++- tests/unit/command/test_plots.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dvc/ui/__init__.py b/dvc/ui/__init__.py index edc40479a..c0466329f 100644 --- a/dvc/ui/__init__.py +++ b/dvc/ui/__init__.py @@ -270,7 +270,9 @@ class Console: path = Path(file).resolve() url = ( - relpath(path) if "Microsoft" in uname().release else path.as_uri() + relpath(path) + if "microsoft" in uname().release.lower() + else path.as_uri() ) opened = webbrowser.open(url) diff --git a/tests/unit/command/test_plots.py b/tests/unit/command/test_plots.py index 6165373b4..9d007c3fb 100644 --- a/tests/unit/command/test_plots.py +++ b/tests/unit/command/test_plots.py @@ -178,7 +178,7 @@ def test_plots_diff_open(tmp_dir, dvc, mocker, capsys, plots_data, auto_open): def test_plots_diff_open_WSL(tmp_dir, dvc, mocker, plots_data): mocked_open = mocker.patch("webbrowser.open", return_value=True) mocked_uname_result = mocker.MagicMock() - mocked_uname_result.release = "Microsoft" + mocked_uname_result.release = "microsoft" mocker.patch("platform.uname", return_value=mocked_uname_result) cli_args = parse_args(