From 61800c619f8f1becd10efa68af4bd41b3aa6768a Mon Sep 17 00:00:00 2001 From: aarif Date: Wed, 7 Aug 2019 16:15:59 +0500 Subject: [PATCH] replaced StringIO imports with import from six replaced cStringIO and StringIO imports with import from six fixed StringIO imports fixed StringIO imports fixed XSS python-wrap warning --- .../management/commands/tests/test_create_course.py | 2 +- .../management/commands/tests/test_export_olx.py | 2 +- .../management/commands/tests/test_git_export.py | 10 +++++----- .../contentstore/views/tests/test_import_export.py | 4 ++-- cms/djangoapps/contentstore/views/tests/test_videos.py | 3 ++- cms/lib/xblock/tagging/test.py | 2 +- .../static_replace/test/test_static_replace.py | 4 +++- .../commands/tests/test_remove_social_auth_users.py | 2 +- .../track/management/tests/test_tracked_command.py | 2 +- common/lib/capa/capa/tests/test_responsetypes.py | 2 +- lms/djangoapps/ccx/views.py | 2 +- .../management/commands/tests/test_dump_course.py | 2 +- lms/djangoapps/dashboard/git_import.py | 4 ++-- .../management/commands/tests/test_git_add_course.py | 6 +++--- lms/djangoapps/dashboard/sysadmin.py | 6 +++--- lms/djangoapps/instructor/views/api.py | 6 +++--- .../instructor_task/tasks_helper/enrollments.py | 2 +- lms/djangoapps/instructor_task/tests/test_models.py | 2 +- .../commands/tests/test_reset_enrollment_data.py | 2 +- lms/djangoapps/shoppingcart/tests/test_reports.py | 10 +++++----- .../course_overviews/tests/test_course_overviews.py | 2 +- .../commands/tests/test_generate_jwt_signing_key.py | 2 +- openedx/tests/xblock_integration/test_recommender.py | 8 ++++---- openedx/tests/xblock_integration/xblock_testcase.py | 2 +- scripts/xsslint/tests/test_main.py | 2 +- 25 files changed, 47 insertions(+), 44 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py index 92a61c8ebf..e388bfbd22 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py @@ -3,7 +3,7 @@ Unittests for creating a course in an chosen modulestore """ from __future__ import absolute_import -from StringIO import StringIO +from six import StringIO import ddt import six diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py b/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py index f4a70dce75..a508505fa3 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_export_olx.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import shutil import tarfile import unittest -from StringIO import StringIO +from six import StringIO from tempfile import mkdtemp import ddt diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py index 2362292fdf..6d8d30433d 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_git_export.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import copy import os import shutil -import StringIO +from six import StringIO import subprocess import unittest from uuid import uuid4 @@ -60,18 +60,18 @@ class TestGitExport(CourseTestCase): test output. """ with self.assertRaisesRegexp(CommandError, 'Error: unrecognized arguments:*'): - call_command('git_export', 'blah', 'blah', 'blah', stderr=StringIO.StringIO()) + call_command('git_export', 'blah', 'blah', 'blah', stderr=StringIO()) with self.assertRaisesMessage(CommandError, 'Error: too few arguments'): - call_command('git_export', stderr=StringIO.StringIO()) + call_command('git_export', stderr=StringIO()) # Send bad url to get course not exported with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.URL_BAD)): - call_command('git_export', 'foo/bar/baz', 'silly', stderr=StringIO.StringIO()) + call_command('git_export', 'foo/bar/baz', 'silly', stderr=StringIO()) # Send bad course_id to get course not exported with self.assertRaisesRegexp(CommandError, six.text_type(GitExportError.BAD_COURSE)): - call_command('git_export', 'foo/bar:baz', 'silly', stderr=StringIO.StringIO()) + call_command('git_export', 'foo/bar:baz', 'silly', stderr=StringIO()) def test_error_output(self): """ diff --git a/cms/djangoapps/contentstore/views/tests/test_import_export.py b/cms/djangoapps/contentstore/views/tests/test_import_export.py index 462fe67e0c..c2b4cb7e06 100644 --- a/cms/djangoapps/contentstore/views/tests/test_import_export.py +++ b/cms/djangoapps/contentstore/views/tests/test_import_export.py @@ -9,7 +9,7 @@ import logging import os import re import shutil -import StringIO +from six import StringIO import tarfile import tempfile from uuid import uuid4 @@ -574,7 +574,7 @@ class ExportTestCase(CourseTestCase): resp = self.client.get(output_url) self._verify_export_succeeded(resp) - buff = StringIO.StringIO(b"".join(resp.streaming_content)) + buff = StringIO("".join(resp.streaming_content)) return tarfile.open(fileobj=buff) def _verify_export_succeeded(self, resp): diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index 9d142adbb4..609e8db127 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -10,6 +10,7 @@ import re from contextlib import contextmanager from datetime import datetime from functools import wraps +from six import StringIO import dateutil.parser import ddt @@ -1416,7 +1417,7 @@ class VideoUrlsCsvTestCase(VideoUploadTestMixin, CourseTestCase): response["Content-Disposition"], u"attachment; filename={course}_video_urls.csv".format(course=self.course.id.course) ) - response_reader = six.StringIO(response.content) + response_reader = StringIO(response.content) reader = csv.DictReader(response_reader, dialect=csv.excel) self.assertEqual( reader.fieldnames, diff --git a/cms/lib/xblock/tagging/test.py b/cms/lib/xblock/tagging/test.py index 781985470d..f0b9c5e034 100644 --- a/cms/lib/xblock/tagging/test.py +++ b/cms/lib/xblock/tagging/test.py @@ -6,7 +6,7 @@ from __future__ import absolute_import import json from datetime import datetime -from StringIO import StringIO +from six import StringIO import ddt import six diff --git a/common/djangoapps/static_replace/test/test_static_replace.py b/common/djangoapps/static_replace/test/test_static_replace.py index c8646fea66..ace36a09fe 100644 --- a/common/djangoapps/static_replace/test/test_static_replace.py +++ b/common/djangoapps/static_replace/test/test_static_replace.py @@ -3,7 +3,7 @@ from __future__ import absolute_import, print_function import re -from cStringIO import StringIO +from six import StringIO from six.moves.urllib.parse import parse_qsl, urlparse, urlunparse import ddt @@ -192,7 +192,9 @@ def test_static_paths_out(mock_modulestore, mock_storage): static_course_url = '/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=%2Fc4x%2Forg%2Fcourse%2Fasset%2FLAlec04_config.xml&name1=value1&name2=value2' raw_url = '/static/js/capa/protex/protex.nocache.js?raw' xblock_url = '/static/xblock/resources/babys_first.lil_xblock/public/images/pacifier.png' + # xss-lint: disable=python-wrap-html pre_text = 'EMBED src ="{}" xblock={} text