Skip to content

Commit

Permalink
[#4801] StringIO is no longer a module on py3
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Nov 21, 2019
1 parent 5db6a46 commit 4bd483b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
2 changes: 0 additions & 2 deletions ckan/tests/controllers/test_api.py
Expand Up @@ -39,8 +39,6 @@ class TestApiController(helpers.FunctionalTestBase):
def test_resource_create_upload_file(self, _):
user = factories.User()
pkg = factories.Dataset(creator_user_id=user['id'])
# upload_content = StringIO()
# upload_content.write('test-content')

url = url_for(
controller='api',
Expand Down
7 changes: 1 addition & 6 deletions ckan/tests/legacy/functional/api/base.py
@@ -1,18 +1,13 @@
# encoding: utf-8

try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO

from nose.tools import assert_equal
from paste.fixture import TestRequest
from webhelpers.html import url_escape

from six.moves.urllib.parse import quote
from six import StringIO

import ckan.model as model
from ckan.tests.legacy import CreateTestData
from ckan.tests.legacy import TestController as ControllerTestCase
from ckan.common import json

Expand Down
6 changes: 3 additions & 3 deletions ckan/tests/legacy/test_coding_standards.py
Expand Up @@ -16,14 +16,14 @@
current coding standards. Please add comments by files that fail if there
are legitimate reasons for the failure.
'''

import cStringIO
import inspect
import itertools
import os
import re
import sys

from six import StringIO

import pycodestyle

file_path = os.path.dirname(__file__)
Expand Down Expand Up @@ -517,7 +517,7 @@ def test_pep8_pass(self):
@classmethod
def find_pep8_errors(cls, filename=None, lines=None):
try:
sys.stdout = cStringIO.StringIO()
sys.stdout = StringIO()
config = {'ignore': [
# W503/W504 - breaking before/after binary operators is agreed
# to not be a concern and was changed to be ignored by default.
Expand Down
3 changes: 2 additions & 1 deletion ckan/tests/lib/test_cli.py
Expand Up @@ -4,14 +4,15 @@
import logging
import os
import os.path
from StringIO import StringIO
import sys
import tempfile

from nose.tools import (assert_raises, eq_ as eq, ok_ as ok, assert_in,
assert_not_in, assert_not_equal as neq, assert_false as nok)
from paste.script.command import run

from six import StringIO

import ckan.lib.cli as cli
import ckan.lib.jobs as jobs
import ckan.tests.helpers as helpers
Expand Down
18 changes: 10 additions & 8 deletions ckan/tests/logic/action/test_create.py
Expand Up @@ -5,7 +5,6 @@
'''
import __builtin__ as builtins

import six

import ckan
import ckan.logic as logic
Expand All @@ -16,6 +15,9 @@
import mock
import nose.tools
from ckan.common import config

from six import string_types, StringIO

from pyfakefs import fake_filesystem

eq = assert_equals = nose.tools.assert_equals
Expand Down Expand Up @@ -523,8 +525,8 @@ def test_mimetype_by_upload_by_filename(self, mock_open):
Real world usage would be using the FileStore API or web UI form to upload a file, with a filename plus extension
If there's no url or the mimetype can't be guessed by the url, mimetype will be guessed by the extension in the filename
'''
import StringIO
test_file = StringIO.StringIO()

test_file = StringIO()
test_file.write('''
"info": {
"title": "BC Data Catalogue API",
Expand Down Expand Up @@ -573,8 +575,8 @@ def test_mimetype_by_upload_by_file(self, mock_open):
Real world usage would be using the FileStore API or web UI form to upload a file, that has no extension
If the mimetype can't be guessed by the url or filename, mimetype will be guessed by the contents inside the file
'''
import StringIO
test_file = StringIO.StringIO()

test_file = StringIO()
test_file.write('''
Snow Course Name, Number, Elev. metres, Date of Survey, Snow Depth cm, Water Equiv. mm, Survey Code, % of Normal, Density %, Survey Period, Normal mm
SKINS LAKE,1B05,890,2015/12/30,34,53,,98,16,JAN-01,54
Expand Down Expand Up @@ -608,8 +610,8 @@ def test_size_of_resource_by_upload(self, mock_open):
'''
The size of the resource determined by the uploaded file
'''
import StringIO
test_file = StringIO.StringIO()

test_file = StringIO()
test_file.write('''
Snow Course Name, Number, Elev. metres, Date of Survey, Snow Depth cm, Water Equiv. mm, Survey Code, % of Normal, Density %, Survey Period, Normal mm
SKINS LAKE,1B05,890,2015/12/30,34,53,,98,16,JAN-01,54
Expand Down Expand Up @@ -991,7 +993,7 @@ def test_return_id_only(self):
context={'return_id_only': True},
)

assert isinstance(dataset, six.string_types)
assert isinstance(dataset, string_types)


class TestGroupCreate(helpers.FunctionalTestBase):
Expand Down
19 changes: 11 additions & 8 deletions ckan/tests/logic/action/test_update.py
Expand Up @@ -14,6 +14,9 @@
import nose.tools
from ckan import model
from ckan.common import config


from six import StringIO
from pyfakefs import fake_filesystem

assert_equals = eq_ = nose.tools.assert_equals
Expand Down Expand Up @@ -1059,8 +1062,8 @@ def test_mimetype_by_upload_by_file(self, mock_open):
url='http://localhost/data.csv',
name='Test')

import StringIO
update_file = StringIO.StringIO()

update_file = StringIO()
update_file.write('''
Snow Course Name, Number, Elev. metres, Date of Survey, Snow Depth cm, Water Equiv. mm, Survey Code, % of Normal, Density %, Survey Period, Normal mm
SKINS LAKE,1B05,890,2015/12/30,34,53,,98,16,JAN-01,54
Expand Down Expand Up @@ -1093,8 +1096,8 @@ def test_mimetype_by_upload_by_filename(self, mock_open):
Real world usage would be using the FileStore API or web UI form to upload a file, with a filename plus extension
If there's no url or the mimetype can't be guessed by the url, mimetype will be guessed by the extension in the filename
'''
import StringIO
test_file = StringIO.StringIO()

test_file = StringIO()
test_file.write('''
"info": {
"title": "BC Data Catalogue API",
Expand Down Expand Up @@ -1122,7 +1125,7 @@ def test_mimetype_by_upload_by_filename(self, mock_open):
name='Test',
upload=test_resource)

update_file = StringIO.StringIO()
update_file = StringIO()
update_file.write('''
Snow Course Name, Number, Elev. metres, Date of Survey, Snow Depth cm, Water Equiv. mm, Survey Code, % of Normal, Density %, Survey Period, Normal mm
SKINS LAKE,1B05,890,2015/12/30,34,53,,98,16,JAN-01,54
Expand Down Expand Up @@ -1173,8 +1176,8 @@ def test_size_of_resource_by_upload(self, mock_open):
'''
The size of the resource determined by the uploaded file
'''
import StringIO
test_file = StringIO.StringIO()

test_file = StringIO()
test_file.write('''
"info": {
"title": "BC Data Catalogue API",
Expand Down Expand Up @@ -1202,7 +1205,7 @@ def test_size_of_resource_by_upload(self, mock_open):
name='Test',
upload=test_resource)

update_file = StringIO.StringIO()
update_file = StringIO()
update_file.write('''
Snow Course Name, Number, Elev. metres, Date of Survey, Snow Depth cm, Water Equiv. mm, Survey Code, % of Normal, Density %, Survey Period, Normal mm
SKINS LAKE,1B05,890,2015/12/30,34,53,,98,16,JAN-01,54
Expand Down
3 changes: 1 addition & 2 deletions ckanext/datastore/backend/postgres.py
Expand Up @@ -10,12 +10,11 @@
import datetime
import hashlib
import json
from cStringIO import StringIO

from six.moves.urllib.parse import (
urlencode, unquote, urlunparse, parse_qsl, urlparse
)
from six import string_types, text_type
from six import string_types, text_type, StringIO

import ckan.lib.cli as cli
import ckan.plugins as p
Expand Down

0 comments on commit 4bd483b

Please sign in to comment.