mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
live: import webbrowser lazily; only patch webbrowser.open
This commit is contained in:
committed by
Saugat Pachhai
parent
fc7caa487f
commit
cab60b54f8
+6
-2
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
from platform import uname
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
@@ -14,7 +13,12 @@ if TYPE_CHECKING:
|
||||
from dvc.output import Output
|
||||
from dvc.repo import Repo
|
||||
|
||||
webbrowser_open = once_per_args(webbrowser.open)
|
||||
|
||||
@once_per_args
|
||||
def webbrowser_open(url: str) -> int:
|
||||
import webbrowser
|
||||
|
||||
return webbrowser.open(url)
|
||||
|
||||
|
||||
def create_summary(out):
|
||||
|
||||
+3
-4
@@ -180,7 +180,6 @@ def custom_template(tmp_dir, dvc):
|
||||
scriptify_fixture = pytest.fixture(lambda: scriptify, name="scriptify")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def webbrowser_open(session_mocker):
|
||||
session_mocker.patch("dvc.repo.live.webbrowser_open")
|
||||
session_mocker.patch("webbrowser.open")
|
||||
@pytest.fixture(autouse=True)
|
||||
def mocked_webbrowser_open(mocker):
|
||||
mocker.patch("webbrowser.open")
|
||||
|
||||
Reference in New Issue
Block a user