14
14
# KIND, either express or implied. See the License for the
15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
+
17
18
import json
18
- import platform
19
19
import sys
20
20
from pathlib import Path
21
21
from unittest import mock
@@ -43,12 +43,13 @@ def test_gets_results(monkeypatch):
43
43
44
44
45
45
def test_uses_environment_variable (monkeypatch ):
46
- monkeypatch .setenv ("SE_MANAGER_PATH" , "/path/to/manager" )
46
+ sm_path = r"\path\to\manager" if sys .platform .startswith ("win" ) else "path/to/manager"
47
+ monkeypatch .setenv ("SE_MANAGER_PATH" , sm_path )
47
48
monkeypatch .setattr (Path , "is_file" , lambda _ : True )
48
49
49
50
binary = SeleniumManager ()._get_binary ()
50
51
51
- assert str (binary ) == "/path/to/manager"
52
+ assert str (binary ) == sm_path
52
53
53
54
54
55
def test_uses_windows (monkeypatch ):
@@ -61,14 +62,19 @@ def test_uses_windows(monkeypatch):
61
62
62
63
def test_uses_linux (monkeypatch ):
63
64
monkeypatch .setattr (sys , "platform" , "linux" )
65
+ monkeypatch .setattr ("platform.machine" , lambda : "x86_64" )
66
+
67
+ binary = SeleniumManager ()._get_binary ()
68
+ project_root = Path (selenium .__file__ ).parent .parent
69
+ assert binary == project_root .joinpath ("selenium/webdriver/common/linux/selenium-manager" )
70
+
71
+
72
+ def test_uses_linux_arm64 (monkeypatch ):
73
+ monkeypatch .setattr (sys , "platform" , "linux" )
74
+ monkeypatch .setattr ("platform.machine" , lambda : "arm64" )
64
75
65
- if platform .machine () == "arm64" :
66
- with pytest .raises (WebDriverException , match = "Unsupported platform/architecture combination: linux/arm64" ):
67
- SeleniumManager ()._get_binary ()
68
- else :
69
- binary = SeleniumManager ()._get_binary ()
70
- project_root = Path (selenium .__file__ ).parent .parent
71
- assert binary == project_root .joinpath ("selenium/webdriver/common/linux/selenium-manager" )
76
+ with pytest .raises (WebDriverException , match = "Unsupported platform/architecture combination: linux/arm64" ):
77
+ SeleniumManager ()._get_binary ()
72
78
73
79
74
80
def test_uses_mac (monkeypatch ):
@@ -97,11 +103,12 @@ def test_errors_if_invalid_os(monkeypatch):
97
103
98
104
99
105
def test_error_if_invalid_env_path (monkeypatch ):
100
- monkeypatch .setenv ("SE_MANAGER_PATH" , "/path/to/manager" )
106
+ sm_path = r"\path\to\manager" if sys .platform .startswith ("win" ) else "path/to/manager"
107
+ monkeypatch .setenv ("SE_MANAGER_PATH" , sm_path )
101
108
102
109
with pytest .raises (WebDriverException ) as excinfo :
103
110
SeleniumManager ()._get_binary ()
104
- assert "Unable to obtain working Selenium Manager binary; /path/to/manager " in str (excinfo .value )
111
+ assert f "Unable to obtain working Selenium Manager binary; { sm_path } " in str (excinfo .value )
105
112
106
113
107
114
def test_run_successful ():
0 commit comments