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
1819import platform
1920import sys
@@ -43,12 +44,13 @@ def test_gets_results(monkeypatch):
4344
4445
4546def test_uses_environment_variable (monkeypatch ):
46- monkeypatch .setenv ("SE_MANAGER_PATH" , "/path/to/manager" )
47+ sm_path = r"\path\to\manager" if sys .platform .startswith ("win" ) else "path/to/manager"
48+ monkeypatch .setenv ("SE_MANAGER_PATH" , sm_path )
4749 monkeypatch .setattr (Path , "is_file" , lambda _ : True )
4850
4951 binary = SeleniumManager ()._get_binary ()
5052
51- assert str (binary ) == "/path/to/manager"
53+ assert str (binary ) == sm_path
5254
5355
5456def test_uses_windows (monkeypatch ):
@@ -59,16 +61,22 @@ def test_uses_windows(monkeypatch):
5961 assert binary == project_root .joinpath ("selenium/webdriver/common/windows/selenium-manager.exe" )
6062
6163
64+
6265def test_uses_linux (monkeypatch ):
6366 monkeypatch .setattr (sys , "platform" , "linux" )
67+ monkeypatch .setattr ("platform.machine" , lambda : "x86_64" )
68+
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" )
6472
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" )
73+
74+ def test_uses_linux_arm64 ( monkeypatch ):
75+ monkeypatch . setattr ( sys , "platform" , "linux" )
76+ monkeypatch . setattr ( "platform.machine" , lambda : "arm64" )
77+
78+ with pytest . raises ( WebDriverException , match = "Unsupported platform/architecture combination: linux/arm64" ):
79+ SeleniumManager (). _get_binary ( )
7280
7381
7482def test_uses_mac (monkeypatch ):
@@ -97,11 +105,12 @@ def test_errors_if_invalid_os(monkeypatch):
97105
98106
99107def test_error_if_invalid_env_path (monkeypatch ):
100- monkeypatch .setenv ("SE_MANAGER_PATH" , "/path/to/manager" )
108+ sm_path = r"\path\to\manager" if sys .platform .startswith ("win" ) else "path/to/manager"
109+ monkeypatch .setenv ("SE_MANAGER_PATH" , sm_path )
101110
102111 with pytest .raises (WebDriverException ) as excinfo :
103112 SeleniumManager ()._get_binary ()
104- assert "Unable to obtain working Selenium Manager binary; /path/to/manager " in str (excinfo .value )
113+ assert f "Unable to obtain working Selenium Manager binary; { sm_path } " in str (excinfo .value )
105114
106115
107116def test_run_successful ():
0 commit comments