def test_text_modes(self):
    text = self.TEXT.decode('ascii')
    text_native_eol = text.replace('\n', os.linesep)
    for mode in ('wt', 'xt'):
        if (mode == 'xt'):
            unlink(self.filename)
        with self.open(self.filename, mode, encoding='ascii') as f:
            f.write(text)
        with open(self.filename, 'rb') as f:
            file_data = ext_decompress(f.read()).decode('ascii')
            self.assertEqual(file_data, text_native_eol)
        with self.open(self.filename, 'rt', encoding='ascii') as f:
            self.assertEqual(f.read(), text)
        with self.open(self.filename, 'at', encoding='ascii') as f:
            f.write(text)
        with open(self.filename, 'rb') as f:
            file_data = ext_decompress(f.read()).decode('ascii')
            self.assertEqual(file_data, (text_native_eol * 2))
def test_text_modes(self):
    text = self.TEXT.decode('ascii')
    text_native_eol = text.replace('\n', os.linesep)
    for mode in ('wt', 'xt'):
        if (mode == 'xt'):
            unlink(self.filename)
        with self.open(self.filename, mode, encoding='ascii') as f:
            f.write(text)
        with open(self.filename, 'rb') as f:
            file_data = ext_decompress(f.read()).decode('ascii')
            self.assertEqual(file_data, text_native_eol)
        with self.open(self.filename, 'rt', encoding='ascii') as f:
            self.assertEqual(f.read(), text)
        with self.open(self.filename, 'at', encoding='ascii') as f:
            f.write(text)
        with open(self.filename, 'rb') as f:
            file_data = ext_decompress(f.read()).decode('ascii')
            self.assertEqual(file_data, (text_native_eol * 2))