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

Method testBadModeArgument

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

Source from the content-addressed store, hash-verified

634 self.assertEqual(cm.filename, __file__)
635
636 def testBadModeArgument(self):
637 # verify that we get a sensible error message for bad mode argument
638 bad_mode = "qwerty"
639 try:
640 f = self.FileIO(TESTFN, bad_mode)
641 except ValueError as msg:
642 if msg.args[0] != 0:
643 s = str(msg)
644 if TESTFN in s or bad_mode not in s:
645 self.fail("bad error message for invalid mode: %s" % s)
646 # if msg.args[0] == 0, we're probably on Windows where there may be
647 # no obvious way to discover why open() failed.
648 else:
649 f.close()
650 self.fail("no error for invalid mode: %s" % bad_mode)
651
652 def testTruncate(self):
653 f = self.FileIO(TESTFN, 'w')

Callers

nothing calls this directly

Calls 3

closeMethod · 0.95
strFunction · 0.85
failMethod · 0.45

Tested by

no test coverage detected