Merge pull request #19591 from cclauss/print_function

Use print() function in both Python 2 and Python 3
This commit is contained in:
Ned Batchelder
2019-01-16 17:59:11 -05:00
committed by GitHub
59 changed files with 312 additions and 253 deletions

View File

@@ -1,6 +1,7 @@
"""
Script for force publishing a course
"""
from __future__ import print_function
from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey

View File

@@ -1,6 +1,7 @@
"""
Testing indexing of the courseware as it is changed
"""
from __future__ import print_function
import json
import time
from datetime import datetime
@@ -674,7 +675,7 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase):
self._do_test_large_course_deletion(store, load_factor)
except: # pylint: disable=bare-except
# Catch any exception here to see when we fail
print "Failed with load_factor of {}".format(load_factor)
print("Failed with load_factor of {}".format(load_factor))
@skip(("This test is to see how we handle very large courses, to ensure that the delete"
"procedure works smoothly - too long to run during the normal course of things"))

View File

@@ -3,6 +3,7 @@
"""
Tests for import_course_from_xml using the mongo modulestore.
"""
from __future__ import print_function
import copy
from uuid import uuid4
@@ -119,7 +120,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
# make sure we have ONE asset in our contentstore ("should_be_imported.html")
all_assets, count = content_store.get_all_content_for_course(course.id)
print "len(all_assets)=%d" % len(all_assets)
print("len(all_assets)=%d" % len(all_assets))
self.assertEqual(len(all_assets), 1)
self.assertEqual(count, 1)
@@ -133,7 +134,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
self.assertIsNotNone(content)
# make sure course.static_asset_path is correct
print "static_asset_path = {0}".format(course.static_asset_path)
print("static_asset_path = {0}".format(course.static_asset_path))
self.assertEqual(course.static_asset_path, 'test_import_course')
def test_asset_import_nostatic(self):
@@ -172,7 +173,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
def test_tab_name_imports_correctly(self):
_module_store, _content_store, course = self.load_test_import_course()
print "course tabs = {0}".format(course.tabs)
print("course tabs = {0}".format(course.tabs))
self.assertEqual(course.tabs[2]['name'], 'Syllabus')
def test_import_performance_mongo(self):

View File

@@ -1,6 +1,7 @@
"""
Common utility functions useful throughout the contentstore
"""
from __future__ import print_function
import logging
from datetime import datetime
@@ -94,7 +95,7 @@ def _remove_instructors(course_key):
"""
In the django layer, remove all the user/groups permissions associated with this course
"""
print 'removing User permissions from course....'
print('removing User permissions from course....')
try:
remove_all_instructors(course_key)

View File

@@ -4,9 +4,10 @@
Group Configuration Tests.
"""
import json
from operator import itemgetter
import ddt
from mock import patch
from operator import itemgetter
from contentstore.utils import reverse_course_url, reverse_usage_url
from contentstore.course_group_config import GroupConfiguration, CONTENT_GROUP_CONFIGURATION_NAME, ENROLLMENT_SCHEME