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

Method test_text_mode

Lib/test/test_tempfile.py:1398–1428  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1396 f.errors
1397
1398 def test_text_mode(self):
1399 # Creating a SpooledTemporaryFile with a text mode should produce
1400 # a file object reading and writing (Unicode) text strings.
1401 f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,
1402 encoding="utf-8")
1403 f.write("abc\n")
1404 f.seek(0)
1405 self.assertEqual(f.read(), "abc\n")
1406 f.write("def\n")
1407 f.seek(0)
1408 self.assertEqual(f.read(), "abc\ndef\n")
1409 self.assertFalse(f._rolled)
1410 self.assertEqual(f.mode, 'w+')
1411 self.assertIsNone(f.name)
1412 self.assertEqual(f.newlines, os.linesep)
1413 self.assertEqual(f.encoding, "utf-8")
1414 self.assertEqual(f.errors, "strict")
1415
1416 f.write("xyzzy\n")
1417 f.seek(0)
1418 self.assertEqual(f.read(), "abc\ndef\nxyzzy\n")
1419 # Check that Ctrl+Z doesn't truncate the file
1420 f.write("foo\x1abar\n")
1421 f.seek(0)
1422 self.assertEqual(f.read(), "abc\ndef\nxyzzy\nfoo\x1abar\n")
1423 self.assertTrue(f._rolled)
1424 self.assertEqual(f.mode, 'w+')
1425 self.assertIsNotNone(f.name)
1426 self.assertEqual(f.newlines, os.linesep)
1427 self.assertEqual(f.encoding, "utf-8")
1428 self.assertEqual(f.errors, "strict")
1429
1430 def test_text_newline_and_encoding(self):
1431 f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,

Callers

nothing calls this directly

Calls 8

writeMethod · 0.95
seekMethod · 0.95
readMethod · 0.95
assertFalseMethod · 0.80
assertIsNoneMethod · 0.80
assertTrueMethod · 0.80
assertIsNotNoneMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected