def test_load_file_to_base64_str_reads_unicode_file_as_base64_string(self): tmp_file_path = os.path.join(self.tmp_dir, 'b64.bin') expected_base64_encoding = u'6YCa' with io.open(tmp_file_path, 'w', encoding='utf-8') as f: f.write(u'\u901a') self.assertEqual(utils.load_file_to_base64_str(tmp_file_path), expected_base64_encoding)
def test_load_file_to_base64_str_reads_text_file_as_base64_string(self): tmp_file_path = os.path.join(self.tmp_dir, 'b64.bin') expected_base64_encoding = u'SGVsbG93IHdvcmxkIQ==' with io.open(tmp_file_path, 'w', encoding='utf-8') as f: f.write(u'Hellow world!') self.assertEqual(utils.load_file_to_base64_str(tmp_file_path), expected_base64_encoding)