You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/02/10 22:45:06 UTC

[allura] 35/41: [#8349] io.open and 'rb' tweaks after 'file' fixer

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8349
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 4bac431ad05d407ab87b6dcbb397845ddc5b2210
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Feb 10 15:40:04 2020 -0500

    [#8349] io.open and 'rb' tweaks after 'file' fixer
---
 Allura/allura/tests/functional/test_admin.py            |  7 ++++---
 Allura/allura/tests/functional/test_home.py             |  3 ++-
 Allura/allura/tests/functional/test_neighborhood.py     |  5 +++--
 ForgeTracker/forgetracker/tests/functional/test_root.py | 17 +++++++++--------
 ForgeWiki/forgewiki/tests/functional/test_rest.py       |  3 ++-
 ForgeWiki/forgewiki/tests/functional/test_root.py       | 11 ++++++-----
 6 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index a55b062..be3a353 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -23,6 +23,7 @@ import allura
 import pkg_resources
 import StringIO
 import logging
+from io import open
 
 import tg
 import PIL
@@ -372,7 +373,7 @@ class TestProjectAdmin(TestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('icon', file_name, file_data)
 
         self.app.get('/admin/')
@@ -396,7 +397,7 @@ class TestProjectAdmin(TestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('screenshot', file_name, file_data)
 
         self.app.get('/admin/')
@@ -436,7 +437,7 @@ class TestProjectAdmin(TestController):
         for file_name in ('admin_24.png', 'admin_32.png'):
             file_path = os.path.join(allura.__path__[0], 'nf', 'allura',
                                      'images', file_name)
-            file_data = open(file_path).read()
+            file_data = open(file_path, 'rb').read()
             upload = ('screenshot', file_name, file_data)
             self.app.post('/admin/add_screenshot', params=dict(
                 caption=file_name),
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index 6955a67..1c65816 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -20,6 +20,7 @@ from __future__ import absolute_import
 import json
 import re
 import os
+from io import open
 
 from tg import tmpl_context as c
 from nose.tools import assert_equal, assert_not_in, assert_in
@@ -157,7 +158,7 @@ class TestProjectHome(TestController):
     def test_user_icon(self):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('icon', file_name, file_data)
         with td.audits('update project icon'):
             self.app.post('/u/test-admin/admin/update', params=dict(
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 672662c..7ebf528 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -22,6 +22,7 @@ import json
 import os
 from cStringIO import StringIO
 import six.moves.urllib.request, six.moves.urllib.error, six.moves.urllib.parse
+from io import open
 
 import PIL
 from mock import patch
@@ -266,7 +267,7 @@ class TestNeighborhood(TestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('icon', file_name, file_data)
 
         r = self.app.get('/adobe/_admin/', extra_environ=dict(username=str('root')))
@@ -869,7 +870,7 @@ class TestNeighborhood(TestController):
         file_name = 'adobe_icon.png'
         file_path = os.path.join(
             allura.__path__[0], 'public', 'nf', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('icon', file_name, file_data)
 
         r = self.app.get('/adobe/_admin/awards',
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index c8e7ae1..3ff8512 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -26,6 +26,7 @@ import json
 import StringIO
 import allura
 import mock
+from io import open
 
 import PIL
 from bs4 import BeautifulSoup
@@ -880,7 +881,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_new_attachment(self):
         file_name = 'test_root.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
         ticket_editor = self.app.post('/bugs/1/update_ticket', {
@@ -895,7 +896,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_delete_attachment(self):
         file_name = 'test_root.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
         ticket_editor = self.app.post('/bugs/1/update_ticket', {
@@ -940,7 +941,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_new_text_attachment_content(self):
         file_name = 'test_root.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
         ticket_editor = self.app.post('/bugs/1/update_ticket', {
@@ -953,7 +954,7 @@ class TestFunctionalController(TrackerTestController):
     def test_two_attachments(self):
         file_name1 = 'test_root1.py'
         file_name2 = 'test_root2.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         self.new_ticket(summary='test new attachment')
         ticket_editor = self.app.post('/bugs/1/update_ticket', {
             'summary': 'zzz'
@@ -967,7 +968,7 @@ class TestFunctionalController(TrackerTestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test new attachment')
         self.app.post('/bugs/1/update_ticket', {
@@ -1672,7 +1673,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_new_ticket_notification_contains_attachments(self):
         file_name = 'tést_root.py'.encode('utf-8')
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('ticket_form.attachment', file_name, file_data)
         r = self.app.post('/bugs/save_ticket', {
             'ticket_form.summary': 'new ticket with attachment'
@@ -2366,7 +2367,7 @@ class TestFunctionalController(TrackerTestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('attachment', file_name, file_data)
         self.new_ticket(summary='test move attachment')
 
@@ -2466,7 +2467,7 @@ class TestFunctionalController(TrackerTestController):
                      11)
 
         file_name = 'test_root.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('attachment', file_name, file_data)
         r = self.app.post('/bugs/1/update_ticket', {
             'summary': 'test rest attach'
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 70e08ca..c860e81 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -20,6 +20,7 @@
 from __future__ import unicode_literals
 from __future__ import absolute_import
 import json
+from io import open
 
 from nose.tools import assert_equal, assert_in, assert_not_equal
 import tg
@@ -48,7 +49,7 @@ class TestWikiApi(TestRestApiBase):
     def test_get_page(self):
         r = self.app.get('/p/test/wiki/Home/')
         discussion_url = r.html.find('form', id='edit_post')['action'][:-4]
-        content = open(__file__).read()
+        content = open(__file__, 'rb').read()
         self.app.post('/wiki/Home/attach',
                       upload_files=[('file_info', 'test_root.py', content)])
         r = self.app.get('/rest/p/test/wiki/Home/')
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index b41ae5e..b2a6022 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -24,6 +24,7 @@ import os
 import StringIO
 import allura
 import json
+from io import open
 
 import PIL
 from nose.tools import assert_true, assert_equal, assert_in, assert_not_equal, assert_not_in
@@ -494,7 +495,7 @@ class TestRootController(TestController):
                 'text': 'sometext',
                 'labels': '',
                 })
-        content = open(__file__).read()
+        content = open(__file__, 'rb').read()
         self.app.post(h.urlquote('/wiki/tést/attach'),
                       upload_files=[('file_info', 'test_root.py', content)])
         response = self.app.get(h.urlquote('/wiki/tést/'))
@@ -508,7 +509,7 @@ class TestRootController(TestController):
                 'text': 'sometext',
                 'labels': '',
                 })
-        content = open(__file__).read()
+        content = open(__file__, 'rb').read()
         self.app.post(h.urlquote('/wiki/tést/attach'),
                       upload_files=[('file_info', 'test1.py', content), ('file_info', 'test2.py', content)])
         response = self.app.get(h.urlquote('/wiki/tést/'))
@@ -524,7 +525,7 @@ class TestRootController(TestController):
                 'labels': '',
                 })
         file_name = 'test_root.py'
-        file_data = open(__file__).read()
+        file_data = open(__file__, 'rb').read()
         upload = ('file_info', file_name, file_data)
         self.app.post(h.urlquote('/wiki/tést/attach'), upload_files=[upload])
         page_editor = self.app.get(h.urlquote('/wiki/tést/edit'))
@@ -540,7 +541,7 @@ class TestRootController(TestController):
         file_name = 'neo-icon-set-454545-256x350.png'
         file_path = os.path.join(
             allura.__path__[0], 'nf', 'allura', 'images', file_name)
-        file_data = open(file_path).read()
+        file_data = open(file_path, 'rb').read()
         upload = ('file_info', file_name, file_data)
         self.app.post('/wiki/TEST/attach', upload_files=[upload])
         h.set_context('test', 'wiki', neighborhood='Projects')
@@ -713,7 +714,7 @@ class TestRootController(TestController):
             'labels': '',
             }
         self.app.post('/wiki/TEST/update', params=params)
-        content = open(__file__).read()
+        content = open(__file__, 'rb').read()
         self.app.post('/wiki/TEST/attach',
                       upload_files=[('file_info', 'test_root.py', content)])
         r = self.app.get('/wiki/TEST/')