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

Method testAbles

Lib/test/test_io/test_fileio.py:513–553  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

511class OtherFileTests:
512
513 def testAbles(self):
514 try:
515 f = self.FileIO(TESTFN, "w")
516 self.assertEqual(f.readable(), False)
517 self.assertEqual(f.writable(), True)
518 self.assertEqual(f.seekable(), True)
519 f.close()
520
521 f = self.FileIO(TESTFN, "r")
522 self.assertEqual(f.readable(), True)
523 self.assertEqual(f.writable(), False)
524 self.assertEqual(f.seekable(), True)
525 f.close()
526
527 f = self.FileIO(TESTFN, "a+")
528 self.assertEqual(f.readable(), True)
529 self.assertEqual(f.writable(), True)
530 self.assertEqual(f.seekable(), True)
531 self.assertEqual(f.isatty(), False)
532 f.close()
533
534 if sys.platform != "win32":
535 try:
536 f = self.FileIO("/dev/tty", "a")
537 except OSError:
538 # When run in a cron job there just aren't any
539 # ttys, so skip the test. This also handles other
540 # OS'es that don't support /dev/tty.
541 pass
542 else:
543 self.assertEqual(f.readable(), False)
544 self.assertEqual(f.writable(), True)
545 if sys.platform != "darwin" and \
546 'bsd' not in sys.platform and \
547 not sys.platform.startswith(('sunos', 'aix')):
548 # Somehow /dev/tty appears seekable on some BSDs
549 self.assertEqual(f.seekable(), False)
550 self.assertEqual(f.isatty(), True)
551 f.close()
552 finally:
553 os.unlink(TESTFN)
554
555 def testInvalidModeStrings(self):
556 # check invalid mode strings

Callers

nothing calls this directly

Calls 8

readableMethod · 0.95
writableMethod · 0.95
seekableMethod · 0.95
closeMethod · 0.95
isattyMethod · 0.95
assertEqualMethod · 0.45
startswithMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected