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

Function setUpModule

Lib/test/test_largefile.py:242–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240
241
242def setUpModule():
243 try:
244 import signal
245 # The default handler for SIGXFSZ is to abort the process.
246 # By ignoring it, system calls exceeding the file size resource
247 # limit will raise OSError instead of crashing the interpreter.
248 signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
249 except (ImportError, AttributeError):
250 pass
251
252 # On Windows and Mac OSX this test consumes large resources; It
253 # takes a long time to build the >2 GiB file and takes >2 GiB of disk
254 # space therefore the resource must be enabled to run this test.
255 # If not, nothing after this line stanza will be executed.
256 if sys.platform[:3] == 'win' or sys.platform == 'darwin':
257 requires('largefile',
258 'test requires %s bytes and a long time to run' % str(size))
259 else:
260 # Only run if the current filesystem supports large files.
261 # (Skip this test on Windows, since we now always support
262 # large files.)
263 f = open(TESTFN, 'wb', buffering=0)
264 try:
265 # 2**31 == 2147483648
266 f.seek(2147483649)
267 # Seeking is not enough of a test: you must write and flush, too!
268 f.write(b'x')
269 f.flush()
270 except (OSError, OverflowError):
271 raise unittest.SkipTest("filesystem does not have "
272 "largefile support")
273 finally:
274 f.close()
275 unlink(TESTFN)
276
277
278class 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