Skip to content

Commit 508d09d

Browse files
committed
remove _read_only_dir fixture -- seems like TemporaryDirectory can handle it: https://github.com/python/cpython/blob/03ceb59e385a8c236795bc6e25a0c767e73aff2d/Lib/tempfile.py#L926
1 parent 8b51830 commit 508d09d

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

mypy/test/testmetastore.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,19 @@
44
import sys
55
import tempfile
66
import unittest
7-
from collections.abc import Iterator
8-
from contextlib import contextmanager
97

108
from mypy.metastore import SqliteMetadataStore
119

1210

13-
@contextmanager
14-
def _read_only_dir(path: str) -> Iterator[str]:
15-
original_mode = os.stat(path).st_mode
16-
os.chmod(path, 0o555)
17-
try:
18-
yield path
19-
finally:
20-
os.chmod(path, original_mode)
21-
22-
2311
@unittest.skipIf(
2412
sys.platform == "win32",
2513
"POSIX chmod semantics: os.chmod(dir, 0o555) does not prevent writes on Windows",
2614
)
2715
class TestSqliteMetadataStore(unittest.TestCase):
2816
def test_init_degrades_to_noop_when_cache_dir_not_creatable(self) -> None:
29-
with tempfile.TemporaryDirectory() as parent, _read_only_dir(parent):
17+
with tempfile.TemporaryDirectory() as parent:
18+
os.chmod(parent, 0o555)
19+
3020
cache_dir = os.path.join(parent, "mypy_cache")
3121

3222
# Must not raise.

0 commit comments

Comments
 (0)