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

Method testAbles

Lib/test/test_fileio.py:514–554  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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