7
7
8
8
import pytest
9
9
10
- from tools .wpt import browser , utils , wpt
10
+ from tools .wpt import browser , wpt
11
11
12
12
13
13
@pytest .mark .slow
14
14
@pytest .mark .remote_network
15
- def test_install_chromium ():
16
- venv_path = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir ())
15
+ def test_install_chromium (tmp_path ):
17
16
channel = "nightly"
18
- dest = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir (), "browsers" , channel )
19
17
if sys .platform == "win32" :
20
- chromium_path = os . path . join ( dest , "chrome-win" )
18
+ chromium_dir = "chrome-win"
21
19
elif sys .platform == "darwin" :
22
- chromium_path = os . path . join ( dest , "chrome-mac" )
20
+ chromium_dir = "chrome-mac"
23
21
else :
24
- chromium_path = os . path . join ( dest , "chrome-linux" )
22
+ chromium_dir = "chrome-linux"
25
23
26
- if os .path .exists (chromium_path ):
27
- utils .rmtree (chromium_path )
28
24
with pytest .raises (SystemExit ) as excinfo :
29
- wpt .main (argv = ["install" , "chromium" , "browser" ])
25
+ wpt .main (argv = ["install" , "-d" , str ( tmp_path ), " chromium" , "browser" ])
30
26
assert excinfo .value .code == 0
31
- assert os .path .exists ( chromium_path )
27
+ assert os .path .isdir ( os . path . join ( tmp_path , "browsers" , channel , chromium_dir ) )
32
28
33
29
chromium = browser .Chromium (logging .getLogger ("Chromium" ))
34
- binary = chromium .find_binary (venv_path , channel )
30
+ binary = chromium .find_binary (str ( tmp_path ) , channel )
35
31
assert binary is not None and os .path .exists (binary )
36
32
37
- utils .rmtree (chromium_path )
38
-
39
33
40
34
@pytest .mark .slow
41
35
@pytest .mark .remote_network
42
- def test_install_chrome ():
43
- venv_path = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir ())
36
+ def test_install_chrome (tmp_path ):
44
37
channel = "dev"
45
- dest = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir (), "browsers" , channel )
46
-
47
38
uname = platform .uname ()
48
39
chrome_platform = {
49
40
"Linux" : "linux" ,
@@ -58,59 +49,46 @@ def test_install_chrome():
58
49
else :
59
50
bits = ""
60
51
61
- chrome_path = os . path . join ( dest , f"chrome-{ chrome_platform } { bits } " )
52
+ chrome_dir = f"chrome-{ chrome_platform } { bits } "
62
53
63
- if os .path .exists (chrome_path ):
64
- utils .rmtree (chrome_path )
65
54
with pytest .raises (SystemExit ) as excinfo :
66
- wpt .main (argv = ["install" , "--channel" , channel , "chrome" , "browser" ])
55
+ wpt .main (argv = ["install" , "-d" , str ( tmp_path ), "- -channel" , channel , "chrome" , "browser" ])
67
56
assert excinfo .value .code == 0
68
- assert os .path .exists ( chrome_path )
57
+ assert os .path .isdir ( os . path . join ( tmp_path , "browsers" , channel , chrome_dir ) )
69
58
70
59
chrome = browser .Chrome (logging .getLogger ("Chrome" ))
71
- binary = chrome .find_binary (venv_path , channel )
60
+ binary = chrome .find_binary (tmp_path , channel )
72
61
assert binary is not None and os .path .exists (binary )
73
62
74
- utils .rmtree (chrome_path )
75
-
76
63
77
64
@pytest .mark .slow
78
65
@pytest .mark .remote_network
79
- def test_install_chrome_chromedriver_by_version ():
66
+ def test_install_chrome_chromedriver_by_version (tmp_path ):
80
67
# This is not technically an integration test as we do not want to require Chrome Stable to run it.
81
68
chrome = browser .Chrome (logging .getLogger ("Chrome" ))
82
69
if sys .platform == "win32" :
83
- dest = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir (), "Scripts" )
84
- chromedriver_path = os .path .join (dest , "chrome" , "chromedriver.exe" )
85
- # By default Windows treats paths as case-insensitive
86
- path_fn = lambda path : path .lower ()
70
+ chromedriver_binary = "chromedriver.exe"
87
71
else :
88
- dest = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir (), "bin" )
89
- chromedriver_path = os .path .join (dest , "chrome" , "chromedriver" )
90
- path_fn = lambda path : path
91
- if os .path .exists (chromedriver_path ):
92
- os .unlink (chromedriver_path )
72
+ chromedriver_binary = "chromedriver"
93
73
# This is a stable version.
94
74
binary_path = chrome .install_webdriver_by_version (
95
- dest = dest , version = "115.0.5790.170" , channel = "stable" )
96
- assert path_fn (binary_path ) == path_fn (chromedriver_path )
97
- assert os .path .exists (chromedriver_path )
98
- os .unlink (chromedriver_path )
75
+ dest = str (tmp_path ), version = "115.0.5790.170" , channel = "stable" )
76
+ assert os .path .samefile (
77
+ binary_path ,
78
+ os .path .join (tmp_path , "chrome" , chromedriver_binary ),
79
+ )
99
80
100
81
101
82
@pytest .mark .slow
102
83
@pytest .mark .remote_network
103
84
@pytest .mark .xfail (sys .platform == "win32" ,
104
85
reason = "https://github.com/web-platform-tests/wpt/issues/17074" )
105
- def test_install_firefox ():
86
+ def test_install_firefox (tmp_path ):
106
87
if sys .platform == "darwin" :
107
- fx_path = os . path . join ( wpt . localpaths . repo_root , wpt . venv_dir (), "browsers" , "nightly" , " Firefox Nightly.app")
88
+ fx_binary = " Firefox Nightly.app"
108
89
else :
109
- fx_path = os .path .join (wpt .localpaths .repo_root , wpt .venv_dir (), "browsers" , "nightly" , "firefox" )
110
- if os .path .exists (fx_path ):
111
- utils .rmtree (fx_path )
90
+ fx_binary = "firefox"
112
91
with pytest .raises (SystemExit ) as excinfo :
113
- wpt .main (argv = ["install" , "firefox" , "browser" , "--channel=nightly" ])
92
+ wpt .main (argv = ["install" , "-d" , str ( tmp_path ), " firefox" , "browser" , "--channel=nightly" ])
114
93
assert excinfo .value .code == 0
115
- assert os .path .exists (fx_path )
116
- utils .rmtree (fx_path )
94
+ assert os .path .exists (os .path .join (tmp_path , "browsers" , "nightly" , fx_binary ))
0 commit comments