Skip to content

Commit 6ea3be3

Browse files
committed
Add tests case
1 parent 1f6e77f commit 6ea3be3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import socket
1212
import stat
1313
import tempfile
14+
import threading
1415
import unittest
1516
from unittest import mock
1617
from urllib.request import pathname2url
@@ -20,6 +21,7 @@
2021
from test.support import is_emscripten, is_wasi, is_wasm32
2122
from test.support import infinite_recursion
2223
from test.support import os_helper
24+
from test.support import threading_helper
2325
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
2426
try:
2527
import fcntl
@@ -1098,6 +1100,27 @@ def test_is_relative_to_windows(self):
10981100
self.assertFalse(p.is_relative_to(P('//z/Share/Foo')))
10991101
self.assertFalse(p.is_relative_to(P('//Server/z/Foo')))
11001102

1103+
@threading_helper.requires_working_threading()
1104+
def test_raw_path_multithread(self):
1105+
P = self.cls
1106+
sep = self.sep
1107+
1108+
NUM_THREADS = 10
1109+
NUM_ITERS = 10
1110+
1111+
for _ in range(NUM_ITERS):
1112+
b = threading.Barrier(NUM_THREADS)
1113+
path = P('a') / 'b' / 'c' / 'd' / 'e'
1114+
expected = sep.join(['a', 'b', 'c', 'd', 'e'])
1115+
1116+
def check_raw_path():
1117+
b.wait()
1118+
self.assertEqual(path._raw_path, expected)
1119+
1120+
threads = [threading.Thread(target=check_raw_path) for _ in range(NUM_THREADS)]
1121+
with threading_helper.start_threads(threads):
1122+
pass
1123+
11011124

11021125
class PurePosixPathTest(PurePathTest):
11031126
cls = pathlib.PurePosixPath

0 commit comments

Comments
 (0)