File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import sys
55import tempfile
66import unittest
7- from collections .abc import Iterator
8- from contextlib import contextmanager
97
108from 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)
2715class 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.
You can’t perform that action at this time.
0 commit comments