Esempio n. 1
0
    def test_open_write_good(self):
        ff = model.TextFileFormat()

        with ff.open() as fh:
            fh.write(self.PAYLOAD)

        with open(str(ff), mode='r', encoding='utf-8') as fh:
            self.assertEqual(self.PAYLOAD, fh.read())
Esempio n. 2
0
    def test_open_write_no_bom(self):
        ff = model.TextFileFormat()

        with ff.open() as fh:
            fh.write(self.PAYLOAD)

        with open(str(ff), mode='rb') as fh:
            self.assertEqual(b'S', fh.read(1))
Esempio n. 3
0
    def test_open_read_ignore_bom(self):
        path = os.path.join(self.test_dir.name, 'file')
        with open(path, 'w', encoding='utf-8-sig') as fh:
            fh.write(self.PAYLOAD)

        ff = model.TextFileFormat(path, mode='r')
        with ff.open() as fh:
            self.assertEqual(self.PAYLOAD, fh.read())