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

Method test_detach

Lib/test/test_io.py:2902–2920  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2900 self.TextIOWrapper(b, encoding="hex")
2901
2902 def test_detach(self):
2903 r = self.BytesIO()
2904 b = self.BufferedWriter(r)
2905 t = self.TextIOWrapper(b, encoding="ascii")
2906 self.assertIs(t.detach(), b)
2907
2908 t = self.TextIOWrapper(b, encoding="ascii")
2909 t.write("howdy")
2910 self.assertFalse(r.getvalue())
2911 t.detach()
2912 self.assertEqual(r.getvalue(), b"howdy")
2913 self.assertRaises(ValueError, t.detach)
2914
2915 # Operations independent of the detached stream should still work
2916 repr(t)
2917 self.assertEqual(t.encoding, "ascii")
2918 self.assertEqual(t.errors, "strict")
2919 self.assertFalse(t.line_buffering)
2920 self.assertFalse(t.write_through)
2921
2922 def test_repr(self):
2923 raw = self.BytesIO("hello".encode("utf-8"))

Callers

nothing calls this directly

Calls 8

detachMethod · 0.95
writeMethod · 0.95
getvalueMethod · 0.95
reprFunction · 0.85
assertFalseMethod · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected