Browse Source

Remove io.open from code

rafalp 6 years ago
parent
commit
5f2d62ed56

+ 1 - 2
misago/users/datadownloads/dataarchive.py

@@ -1,4 +1,3 @@
-import io  # fixme: remove explicit io imports after going py3k-only
 import os
 import shutil
 
@@ -78,7 +77,7 @@ class DataArchive(object):
         clean_filename = slugify(str(name))
         file_dir_path = self.make_final_path(date=date, directory=directory)
         file_path = os.path.join(file_dir_path, '{}.txt'.format(clean_filename))
-        with io.open(file_path, 'w', encoding='utf-8') as fp:
+        with open(file_path, 'w') as fp:
             fp.write(six.text_type(value))
             return file_path
 

+ 7 - 8
misago/users/tests/test_datadownloads_dataarchive.py

@@ -1,4 +1,3 @@
-import io  # fixme: remove explicit io imports after going py3k-only
 import os
 from collections import OrderedDict
 
@@ -62,7 +61,7 @@ class DataArchiveTests(AuthenticatedUserTestCase):
             valid_output_path = os.path.join(archive.data_dir_path, 'testfile.txt')
             self.assertEqual(file_path, valid_output_path)
 
-            with io.open(file_path, 'r', encoding="utf-8") as fp:
+            with open(file_path, 'r') as fp:
                 saved_data = fp.read().strip()
                 self.assertEqual(saved_data, data_to_write)
 
@@ -76,7 +75,7 @@ class DataArchiveTests(AuthenticatedUserTestCase):
             valid_output_path = os.path.join(archive.data_dir_path, 'testfile.txt')
             self.assertEqual(file_path, valid_output_path)
 
-            with io.open(file_path, 'r', encoding="utf-8") as fp:
+            with open(file_path, 'r') as fp:
                 saved_data = fp.read().strip()
                 self.assertEqual(saved_data, str(data_to_write))
 
@@ -90,7 +89,7 @@ class DataArchiveTests(AuthenticatedUserTestCase):
             valid_output_path = os.path.join(archive.data_dir_path, 'testfile.txt')
             self.assertEqual(file_path, valid_output_path)
 
-            with io.open(file_path, 'r', encoding="utf-8") as fp:
+            with open(file_path, 'r') as fp:
                 saved_data = fp.read().strip()
                 # order of dict items in py<3.6 is non-deterministic
                 # making testing for exact match a mistake
@@ -107,13 +106,13 @@ class DataArchiveTests(AuthenticatedUserTestCase):
             valid_output_path = os.path.join(archive.data_dir_path, 'testfile.txt')
             self.assertEqual(file_path, valid_output_path)
 
-            with io.open(file_path, 'r', encoding="utf-8") as fp:
+            with open(file_path, 'r') as fp:
                 saved_data = fp.read().strip()
                 self.assertEqual(saved_data, "first: łorld!\nsecond: łup!")
 
     def test_add_model_file(self):
         """add_model_file method adds model file"""
-        with io.open(TEST_AVATAR_PATH, 'rb') as avatar:
+        with open(TEST_AVATAR_PATH, 'rb') as avatar:
             self.user.avatar_tmp = File(avatar)
             self.user.save()
 
@@ -135,7 +134,7 @@ class DataArchiveTests(AuthenticatedUserTestCase):
 
     def test_add_model_file_prefixed(self):
         """add_model_file method adds model file with prefix"""
-        with io.open(TEST_AVATAR_PATH, 'rb') as avatar:
+        with open(TEST_AVATAR_PATH, 'rb') as avatar:
             self.user.avatar_tmp = File(avatar)
             self.user.save()
 
@@ -205,7 +204,7 @@ class DataArchiveTests(AuthenticatedUserTestCase):
         """get_file returns django file"""
         django_file = None
         
-        with io.open(TEST_AVATAR_PATH, 'rb') as avatar:
+        with open(TEST_AVATAR_PATH, 'rb') as avatar:
             self.user.avatar_tmp = File(avatar)
             self.user.save()