File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import os
33
44from webdriver_manager .core .constants import ROOT_FOLDER_NAME , get_default_user_home_cache_path
5+ from webdriver_manager .core .constants import get_default_project_root_cache_path
56
67
78def test_default_user_home_cache_path_falls_back_to_temp_if_home_is_root (monkeypatch ):
@@ -18,3 +19,13 @@ def test_default_user_home_cache_path_falls_back_to_temp_if_home_is_unresolved(m
1819 cache_path = get_default_user_home_cache_path ()
1920
2021 assert cache_path == os .path .join (tempfile .gettempdir (), ROOT_FOLDER_NAME )
22+
23+
24+ def test_default_project_root_cache_path_uses_cwd_for_frozen_app (monkeypatch ):
25+ monkeypatch .setattr ("sys.path" , ["C:/app/base_library.zip" ])
26+ monkeypatch .setattr ("sys.frozen" , True , raising = False )
27+ monkeypatch .setattr ("os.getcwd" , lambda : "C:/app/runtime" )
28+
29+ cache_path = get_default_project_root_cache_path ()
30+
31+ assert cache_path == os .path .join ("C:/app/runtime" , ROOT_FOLDER_NAME )
Original file line number Diff line number Diff line change 33import tempfile
44
55ROOT_FOLDER_NAME = ".wdm"
6- DEFAULT_PROJECT_ROOT_CACHE_PATH = os .path .join (sys .path [0 ], ROOT_FOLDER_NAME )
6+
7+
8+ def get_default_project_root_cache_path ():
9+ base_path = sys .path [0 ]
10+ if getattr (sys , "frozen" , False ) or base_path .endswith (".zip" ):
11+ base_path = os .getcwd ()
12+ return os .path .join (base_path , ROOT_FOLDER_NAME )
13+
14+
15+ DEFAULT_PROJECT_ROOT_CACHE_PATH = get_default_project_root_cache_path ()
716
817
918def get_default_user_home_cache_path ():
You can’t perform that action at this time.
0 commit comments