()
| 258 | |
| 259 | |
| 260 | def 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 | |
| 296 | class CLargeFileTest(TestFileMethods, unittest.TestCase): |
nothing calls this directly
no test coverage detected
searching dependent graphs…