| 658 | self.assertEqual(0, len(g.readchunk())) |
| 659 | |
| 660 | def test_write_unicode(self): |
| 661 | f = GridIn(self.db.fs) |
| 662 | with self.assertRaises(TypeError): |
| 663 | f.write("foo") |
| 664 | |
| 665 | f = GridIn(self.db.fs, encoding="utf-8") |
| 666 | f.write("foo") |
| 667 | f.close() |
| 668 | |
| 669 | g = GridOut(self.db.fs, f._id) |
| 670 | self.assertEqual(b"foo", g.read()) |
| 671 | |
| 672 | f = GridIn(self.db.fs, encoding="iso-8859-1") |
| 673 | f.write("aé") |
| 674 | f.close() |
| 675 | |
| 676 | g = GridOut(self.db.fs, f._id) |
| 677 | self.assertEqual("aé".encode("iso-8859-1"), g.read()) |
| 678 | |
| 679 | def test_set_after_close(self): |
| 680 | f = GridIn(self.db.fs, _id="foo", bar="baz") |