Skip to content

Commit 9363769

Browse files
authored
gh-109295: Skip test_generated_cases if different mount drives (#109308)
On Windows, skip the test if the current working directory and the Python source code directory have different mount drives. It happens if the temporary directory is on a different mount drive than the Python source code.
1 parent f2a55fe commit 9363769

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Lib/test/test_generated_cases.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
import contextlib
2+
import os
3+
import sys
24
import tempfile
35
import unittest
4-
import os
56

67
from test import support
78
from test import test_tools
89

10+
11+
def skip_if_different_mount_drives():
12+
if sys.platform != 'win32':
13+
return
14+
ROOT = os.path.dirname(os.path.dirname(__file__))
15+
root_drive = os.path.splitroot(ROOT)[0]
16+
cwd_drive = os.path.splitroot(os.getcwd())[0]
17+
if root_drive != cwd_drive:
18+
# generate_cases.py uses relpath() which raises ValueError if ROOT
19+
# and the current working different have different mount drives
20+
# (on Windows).
21+
raise unittest.SkipTest(
22+
f"the current working directory and the Python source code "
23+
f"directory have different mount drives "
24+
f"({cwd_drive} and {root_drive})"
25+
)
26+
skip_if_different_mount_drives()
27+
28+
929
test_tools.skip_if_missing('cases_generator')
1030
with test_tools.imports_under_tool('cases_generator'):
1131
import generate_cases

0 commit comments

Comments
 (0)