Skip to content

Commit 7e029b2

Browse files
committed
code review
1 parent 519625b commit 7e029b2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from functools import cached_property
1919

2020
from test.support import MISSING_C_DOCSTRINGS
21-
from test.support.os_helper import EnvironmentVarGuard
21+
from test.support.os_helper import EnvironmentVarGuard, FakePath
2222
from test.test_zoneinfo import _support as test_support
2323
from test.test_zoneinfo._support import TZPATH_TEST_LOCK, ZoneInfoTestBase
2424
from test.support.import_helper import import_module, CleanImport
@@ -1784,7 +1784,7 @@ def test_reset_tzpath_relative_paths(self):
17841784
("/usr/share/zoneinfo", "../relative/path",),
17851785
("path/to/somewhere", "../relative/path",),
17861786
("/usr/share/zoneinfo", "path/to/somewhere", "../relative/path",),
1787-
(pathlib.Path("path/to/somewhere"),)
1787+
(FakePath("path/to/somewhere"),)
17881788
]
17891789
for input_paths in bad_values:
17901790
with self.subTest(input_paths=input_paths):
@@ -1797,6 +1797,8 @@ def test_tzpath_type_error(self):
17971797
b"/etc/zoneinfo:/usr/share/zoneinfo",
17981798
0,
17991799
(b"/bytes/path", "/valid/path"),
1800+
(FakePath(b"/bytes/path"),),
1801+
(0,),
18001802
]
18011803

18021804
for bad_value in bad_values:
@@ -1807,7 +1809,7 @@ def test_tzpath_type_error(self):
18071809
def test_tzpath_attribute(self):
18081810
tzpath_0 = [f"{DRIVE}/one", f"{DRIVE}/two"]
18091811
tzpath_1 = [f"{DRIVE}/three"]
1810-
tzpath_pathlike = (pathlib.Path("{DRIVE}/usr/share/zoneinfo"),)
1812+
tzpath_pathlike = (FakePath(f"{DRIVE}/usr/share/zoneinfo"),)
18111813

18121814
with self.tzpath_context(tzpath_0):
18131815
query_0 = self.module.TZPATH

Lib/zoneinfo/_tzpath.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def _reset_tzpath(to=None, stacklevel=4):
1414
)
1515

1616
tzpaths = [os.fspath(p) for p in tzpaths]
17-
nonstr_paths = [p for p in tzpaths if not isinstance(p, str)]
18-
if nonstr_paths:
17+
if not all(isinstance(p, str) for p in tzpaths):
1918
raise TypeError(
2019
"All elements of a tzpath sequence must be strings or "
2120
"os.PathLike objects which convert to strings."

0 commit comments

Comments
 (0)