def test_file_bin_read_unicode_as_bin(self): """Test read of unicode as binary with decode""" FileWriter(self.unicode_path).write_utf8(self.unicode_string) bin_data = FileReader( self.unicode_path).read_bin() #read unicode file as binary uni_text = bin_data.decode("utf-8") #decode to utf-8 self.assertEqual(uni_text, self.unicode_string)
def test_file_gzip_ascii_readwrite(self): """Test gzip compression and read from compressed ascii text file in Python 2""" if state.py2: FileWriter(self.ascii_path).gzip(self.ascii_string) gzip_contents = FileReader(self.ascii_path + ".gz").read_gzip() self.assertEqual(gzip_contents, self.ascii_string) elif state.py3: FileWriter(self.ascii_path).gzip(bytes(self.ascii_string, 'utf-8')) gzip_contents = FileReader(self.ascii_path + ".gz").read_gzip() self.assertEqual(gzip_contents.decode('ascii'), self.ascii_string)
def test_file_gzip_ascii_readwrite(self): """Test gzip compression and read from compressed ascii text file in Python 2""" if state.py2: FileWriter(self.ascii_path).gzip(self.ascii_string) gzip_contents = FileReader(self.ascii_path + ".gz").read_gzip() self.assertEqual(gzip_contents, self.ascii_string) elif state.py3: FileWriter(self.ascii_path).gzip( bytes(self.ascii_string, 'utf-8')) gzip_contents = FileReader(self.ascii_path + ".gz").read_gzip() self.assertEqual(gzip_contents.decode('ascii'), self.ascii_string)
def test_file_bin_read_unicode_as_bin(self): """Test read of unicode as binary with decode""" FileWriter(self.unicode_path).write_utf8(self.unicode_string) bin_data = FileReader(self.unicode_path).read_bin() #read unicode file as binary uni_text = bin_data.decode("utf-8") #decode to utf-8 self.assertEqual(uni_text, self.unicode_string)