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

Method test_open

Lib/test/test_builtin.py:1702–1715  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1700 fp.write('YYY'*100)
1701
1702 def test_open(self):
1703 self.write_testfile()
1704 fp = open(TESTFN, encoding="utf-8")
1705 with fp:
1706 self.assertEqual(fp.readline(4), '1+1\n')
1707 self.assertEqual(fp.readline(), 'The quick brown fox jumps over the lazy dog.\n')
1708 self.assertEqual(fp.readline(4), 'Dear')
1709 self.assertEqual(fp.readline(100), ' John\n')
1710 self.assertEqual(fp.read(300), 'XXX'*100)
1711 self.assertEqual(fp.read(1000), 'YYY'*100)
1712
1713 # embedded null bytes and characters
1714 self.assertRaises(ValueError, open, 'a\x00b')
1715 self.assertRaises(ValueError, open, b'a\x00b')
1716
1717 @unittest.skipIf(sys.flags.utf8_mode, "utf-8 mode is enabled")
1718 def test_open_default_encoding(self):

Callers

nothing calls this directly

Calls 6

write_testfileMethod · 0.95
openFunction · 0.50
assertEqualMethod · 0.45
readlineMethod · 0.45
readMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected