1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17+
1718import json
18- import platform
1919import sys
2020from pathlib import Path
2121from unittest import mock
@@ -43,12 +43,13 @@ def test_gets_results(monkeypatch):
4343
4444
4545def 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 )
4748 monkeypatch .setattr (Path , "is_file" , lambda _ : True )
4849
4950 binary = SeleniumManager ()._get_binary ()
5051
51- assert str (binary ) == "/path/to/manager"
52+ assert str (binary ) == sm_path
5253
5354
5455def test_uses_windows (monkeypatch ):
@@ -61,14 +62,19 @@ def test_uses_windows(monkeypatch):
6162
6263def test_uses_linux (monkeypatch ):
6364 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" )
6475
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 ()
7278
7379
7480def test_uses_mac (monkeypatch ):
@@ -97,11 +103,12 @@ def test_errors_if_invalid_os(monkeypatch):
97103
98104
99105def 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 )
101108
102109 with pytest .raises (WebDriverException ) as excinfo :
103110 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 )
105112
106113
107114def test_run_successful ():
0 commit comments