MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_closerange

Method test_closerange

Lib/test/test_os.py:193–212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

191 support.is_wasi, "WASI does not support dup."
192 )
193 def test_closerange(self):
194 first = os.open(os_helper.TESTFN, os.O_CREAT|os.O_RDWR)
195 # We must allocate two consecutive file descriptors, otherwise
196 # it will mess up other file descriptors (perhaps even the three
197 # standard ones).
198 second = os.dup(first)
199 try:
200 retries = 0
201 while second != first + 1:
202 os.close(first)
203 retries += 1
204 if retries > 10:
205 # XXX test skipped
206 self.skipTest("couldn't allocate two consecutive fds")
207 first, second = second, os.dup(second)
208 finally:
209 os.close(second)
210 # close a fd that is open, and one that isn't
211 os.closerange(first, first + 2)
212 self.assertRaises(OSError, os.write, first, b"a")
213
214 @support.cpython_only
215 def test_rename(self):

Callers

nothing calls this directly

Calls 5

skipTestMethod · 0.80
openMethod · 0.45
dupMethod · 0.45
closeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected