Skip to content

Commit f1ac623

Browse files
committed
Test Path.parts instead of private _raw_path property
1 parent 6ea3be3 commit f1ac623

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

Lib/test/test_pathlib/test_join.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"""
44

55
import unittest
6+
import threading
7+
from test.support import threading_helper
68

79
from .support import is_pypi
810
from .support.lexical_path import LexicalPath
@@ -158,6 +160,26 @@ def test_parts(self):
158160
parts = p.parts
159161
self.assertEqual(parts, (sep, 'a', 'b'))
160162

163+
@threading_helper.requires_working_threading()
164+
def test_parts_multithreaded(self):
165+
P = self.cls
166+
167+
NUM_THREADS = 10
168+
NUM_ITERS = 10
169+
170+
for _ in range(NUM_ITERS):
171+
b = threading.Barrier(NUM_THREADS)
172+
path = P('a') / 'b' / 'c' / 'd' / 'e'
173+
expected = ('a', 'b', 'c', 'd', 'e')
174+
175+
def check_parts():
176+
b.wait()
177+
self.assertEqual(path.parts, expected)
178+
179+
threads = [threading.Thread(target=check_parts) for _ in range(NUM_THREADS)]
180+
with threading_helper.start_threads(threads):
181+
pass
182+
161183
def test_parent(self):
162184
# Relative
163185
P = self.cls

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import socket
1212
import stat
1313
import tempfile
14-
import threading
1514
import unittest
1615
from unittest import mock
1716
from urllib.request import pathname2url
@@ -21,7 +20,6 @@
2120
from test.support import is_emscripten, is_wasi, is_wasm32
2221
from test.support import infinite_recursion
2322
from test.support import os_helper
24-
from test.support import threading_helper
2523
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
2624
try:
2725
import fcntl
@@ -1100,27 +1098,6 @@ def test_is_relative_to_windows(self):
11001098
self.assertFalse(p.is_relative_to(P('//z/Share/Foo')))
11011099
self.assertFalse(p.is_relative_to(P('//Server/z/Foo')))
11021100

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-
11241101

11251102
class PurePosixPathTest(PurePathTest):
11261103
cls = pathlib.PurePosixPath

0 commit comments

Comments
 (0)