MCPcopy Index your code
hub / github.com/python/cpython / setUpModule

Function setUpModule

Lib/test/test_io/test_largefile.py:260–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258
259
260def setUpModule():
261 try:
262 import signal
263 # The default handler for SIGXFSZ is to abort the process.
264 # By ignoring it, system calls exceeding the file size resource
265 # limit will raise OSError instead of crashing the interpreter.
266 signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
267 except (ImportError, AttributeError):
268 pass
269
270 # On Windows and Mac OSX this test consumes large resources; It
271 # takes a long time to build the >2 GiB file and takes >2 GiB of disk
272 # space therefore the resource must be enabled to run this test.
273 # If not, nothing after this line stanza will be executed.
274 if sys.platform[:3] == 'win' or sys.platform == 'darwin':
275 requires('largefile',
276 'test requires %s bytes and a long time to run' % str(size))
277 else:
278 # Only run if the current filesystem supports large files.
279 # (Skip this test on Windows, since we now always support
280 # large files.)
281 f = open(TESTFN, 'wb', buffering=0)
282 try:
283 # 2**31 == 2147483648
284 f.seek(2147483649)
285 # Seeking is not enough of a test: you must write and flush, too!
286 f.write(b'x')
287 f.flush()
288 except (OSError, OverflowError):
289 raise unittest.SkipTest("filesystem does not have "
290 "largefile support")
291 finally:
292 f.close()
293 unlink(TESTFN)
294
295
296class CLargeFileTest(TestFileMethods, unittest.TestCase):

Callers

nothing calls this directly

Calls 8

requiresFunction · 0.90
unlinkFunction · 0.90
strFunction · 0.85
openFunction · 0.50
seekMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…