Use print() function in both Python 2 and Python 3
This commit is contained in:
@@ -10,6 +10,7 @@ file and check it in at the same time as your model changes. To do that,
|
||||
2. ./manage.py lms schemamigration student --auto description_of_your_change
|
||||
3. Add the migration file created in edx-platform/common/djangoapps/student/migrations/
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
@@ -2148,12 +2149,12 @@ def get_user(email):
|
||||
|
||||
def user_info(email):
|
||||
user, u_prof = get_user(email)
|
||||
print "User id", user.id
|
||||
print "Username", user.username
|
||||
print "E-mail", user.email
|
||||
print "Name", u_prof.name
|
||||
print "Location", u_prof.location
|
||||
print "Language", u_prof.language
|
||||
print("User id", user.id)
|
||||
print("Username", user.username)
|
||||
print("E-mail", user.email)
|
||||
print("Name", u_prof.name)
|
||||
print("Location", u_prof.location)
|
||||
print("Language", u_prof.language)
|
||||
return user, u_prof
|
||||
|
||||
|
||||
@@ -2170,8 +2171,8 @@ def change_name(email, new_name):
|
||||
|
||||
|
||||
def user_count():
|
||||
print "All users", User.objects.all().count()
|
||||
print "Active users", User.objects.filter(is_active=True).count()
|
||||
print("All users", User.objects.all().count())
|
||||
print("Active users", User.objects.filter(is_active=True).count())
|
||||
return User.objects.all().count()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Command-line utility to start a stub service.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
@@ -37,7 +38,7 @@ def get_args():
|
||||
Exits with a message if arguments are invalid.
|
||||
"""
|
||||
if len(sys.argv) < 3:
|
||||
print USAGE
|
||||
print(USAGE)
|
||||
sys.exit(1)
|
||||
|
||||
service_name = sys.argv[1]
|
||||
@@ -45,8 +46,8 @@ def get_args():
|
||||
config_dict = _parse_config_args(sys.argv[3:])
|
||||
|
||||
if service_name not in SERVICES:
|
||||
print "Unrecognized service '{0}'. Valid choices are: {1}".format(
|
||||
service_name, ", ".join(SERVICES.keys()))
|
||||
print("Unrecognized service '{0}'. Valid choices are: {1}".format(
|
||||
service_name, ", ".join(SERVICES.keys())))
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
@@ -55,7 +56,7 @@ def get_args():
|
||||
raise ValueError
|
||||
|
||||
except ValueError:
|
||||
print "Port '{0}' must be a positive integer".format(port_num)
|
||||
print("Port '{0}' must be a positive integer".format(port_num))
|
||||
sys.exit(1)
|
||||
|
||||
return service_name, port_num, config_dict
|
||||
@@ -77,7 +78,7 @@ def _parse_config_args(args):
|
||||
config_dict[components[0]] = "=".join(components[1:])
|
||||
|
||||
except:
|
||||
print "Warning: could not interpret config value '{0}'".format(config_str)
|
||||
print("Warning: could not interpret config value '{0}'".format(config_str))
|
||||
|
||||
return config_dict
|
||||
|
||||
@@ -87,7 +88,7 @@ def main():
|
||||
Start a server; shut down on keyboard interrupt signal.
|
||||
"""
|
||||
service_name, port_num, config_dict = get_args()
|
||||
print "Starting stub service '{0}' on port {1}...".format(service_name, port_num)
|
||||
print("Starting stub service '{0}' on port {1}...".format(service_name, port_num))
|
||||
|
||||
server = SERVICES[service_name](port_num=port_num)
|
||||
server.config.update(config_dict)
|
||||
@@ -97,7 +98,7 @@ def main():
|
||||
time.sleep(1)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print "Stopping stub service..."
|
||||
print("Stopping stub service...")
|
||||
|
||||
finally:
|
||||
server.shutdown()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Creates Indexes on contentstore and modulestore databases.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from xmodule.contentstore.django import contentstore
|
||||
@@ -17,4 +18,4 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
contentstore().ensure_indexes()
|
||||
modulestore().ensure_indexes()
|
||||
print 'contentstore and modulestore indexes created!'
|
||||
print('contentstore and modulestore indexes created!')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Commandline tool for doing operations on Problems
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
@@ -67,7 +68,7 @@ def main():
|
||||
|
||||
def command_show(problem):
|
||||
"""Display the text for this problem"""
|
||||
print problem.get_html()
|
||||
print(problem.get_html())
|
||||
|
||||
|
||||
def command_test(problem):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests the capa shuffle and name-masking."""
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import textwrap
|
||||
@@ -276,7 +277,7 @@ class CapaShuffleTest(unittest.TestCase):
|
||||
orig_html = problem.get_html()
|
||||
self.assertEqual(orig_html, problem.get_html(), 'should be able to call get_html() twice')
|
||||
html = orig_html.replace('\n', ' ') # avoid headaches with .* matching
|
||||
print html
|
||||
print(html)
|
||||
self.assertRegexpMatches(html, r"<div>.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*</div>.*" +
|
||||
r"<div>.*\[.*'C'.*'A'.*'D'.*'B'.*\].*</div>")
|
||||
# Look at the responses in their authored order
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import codecs
|
||||
import unittest
|
||||
from fractions import Fraction
|
||||
@@ -12,7 +13,7 @@ LOCAL_DEBUG = None
|
||||
def log(msg, output_type=None):
|
||||
"""Logging function for tests"""
|
||||
if LOCAL_DEBUG:
|
||||
print msg
|
||||
print(msg)
|
||||
if output_type == 'html':
|
||||
f.write(msg + '\n<br>\n')
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ values in parameterized problems. For details, see:
|
||||
|
||||
http://en.wikipedia.org/wiki/Electronic_color_code
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
# r is standard name for a resistor. We would like to use it as such.
|
||||
@@ -91,21 +92,21 @@ def iseia(r, valid_types=(E6, E12, E24)):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Test cases. All of these should return True
|
||||
print iseia(100) # 100 ohm resistor is EIA
|
||||
print not iseia(101) # 101 is not
|
||||
print not iseia(100.3) # Floating point close to EIA is not EIA
|
||||
print iseia(100.001) # But within floating point error is
|
||||
print iseia(1e5) # We handle big numbers well
|
||||
print iseia(2200) # We handle middle-of-the-list well
|
||||
print(iseia(100)) # 100 ohm resistor is EIA
|
||||
print(not iseia(101)) # 101 is not
|
||||
print(not iseia(100.3)) # Floating point close to EIA is not EIA
|
||||
print(iseia(100.001)) # But within floating point error is
|
||||
print(iseia(1e5)) # We handle big numbers well
|
||||
print(iseia(2200)) # We handle middle-of-the-list well
|
||||
# We can handle 1% components correctly; 2.2k is EIA24, but not EIA48.
|
||||
print not iseia(2200, (E48, E96, E192))
|
||||
print iseia(5490e2, (E48, E96, E192))
|
||||
print iseia(2200)
|
||||
print not iseia(5490e2)
|
||||
print iseia(1e-5) # We handle little numbers well
|
||||
print not iseia("Hello") # Junk handled okay
|
||||
print not iseia(float('NaN'))
|
||||
print not iseia(-1)
|
||||
print not iseia(iseia)
|
||||
print not iseia(float('Inf'))
|
||||
print iseia(0) # Corner case. 0 is a standard resistor value.
|
||||
print(not iseia(2200, (E48, E96, E192)))
|
||||
print(iseia(5490e2, (E48, E96, E192)))
|
||||
print(iseia(2200))
|
||||
print(not iseia(5490e2))
|
||||
print(iseia(1e-5)) # We handle little numbers well
|
||||
print(not iseia("Hello")) # Junk handled okay
|
||||
print(not iseia(float('NaN')))
|
||||
print(not iseia(-1))
|
||||
print(not iseia(iseia))
|
||||
print(not iseia(float('Inf')))
|
||||
print(iseia(0)) # Corner case. 0 is a standard resistor value.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from .django import contentstore
|
||||
|
||||
@@ -12,13 +13,13 @@ def empty_asset_trashcan(course_locs):
|
||||
# first delete all of the thumbnails
|
||||
thumbs = store.get_all_content_thumbnails_for_course(course_loc)
|
||||
for thumb in thumbs:
|
||||
print "Deleting {0}...".format(thumb)
|
||||
print("Deleting {0}...".format(thumb))
|
||||
store.delete(thumb['_id'])
|
||||
|
||||
# then delete all of the assets
|
||||
assets, __ = store.get_all_content_for_course(course_loc)
|
||||
for asset in assets:
|
||||
print "Deleting {0}...".format(asset)
|
||||
print("Deleting {0}...".format(asset))
|
||||
store.delete(asset['_id'])
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"""
|
||||
Generates fake XML for asset metadata.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import random
|
||||
from lxml import etree
|
||||
@@ -233,4 +234,4 @@ if __name__ == '__main__':
|
||||
if click is not None:
|
||||
cli() # pylint: disable=no-value-for-parameter
|
||||
else:
|
||||
print "Aborted! Module 'click' is not installed."
|
||||
print("Aborted! Module 'click' is not installed.")
|
||||
|
||||
@@ -4,6 +4,7 @@ Reads the data generated by performance tests and generates a savable
|
||||
report which can be viewed over time to examine the performance effects of code changes on
|
||||
various parts of the system.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import sqlite3
|
||||
from lxml.builder import E
|
||||
@@ -286,4 +287,4 @@ if __name__ == '__main__':
|
||||
if click is not None:
|
||||
cli() # pylint: disable=no-value-for-parameter
|
||||
else:
|
||||
print "Aborted! Module 'click' is not installed."
|
||||
print("Aborted! Module 'click' is not installed.")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Factories for use in tests of XBlocks.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import datetime
|
||||
import functools
|
||||
@@ -584,7 +585,7 @@ def check_sum_of_calls(object_, methods, maximum_calls, minimum_calls=1, include
|
||||
messages.append(" args: {}\n".format(args))
|
||||
messages.append(" kwargs: {}\n\n".format(dict(kwargs)))
|
||||
|
||||
print "".join(messages)
|
||||
print("".join(messages))
|
||||
|
||||
# verify the counter actually worked by ensuring we have counted greater than (or equal to) the minimum calls
|
||||
assert call_count >= minimum_calls
|
||||
|
||||
@@ -20,6 +20,7 @@ Modulestore virtual | XML physical (draft, published)
|
||||
(a, a) | (a, a) | (x, a) | (x, x) | (x, y) | (a, x)
|
||||
(a, b) | (a, b) | (x, b) | (x, x) | (x, y) | (a, x)
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import json
|
||||
import logging
|
||||
import mimetypes
|
||||
@@ -1177,7 +1178,7 @@ def perform_xlint(
|
||||
for err_log in module_store.errored_courses.itervalues():
|
||||
for err_log_entry in err_log.errors:
|
||||
msg = err_log_entry[0]
|
||||
print msg
|
||||
print(msg)
|
||||
if msg.startswith('ERROR:'):
|
||||
err_cnt += 1
|
||||
else:
|
||||
@@ -1220,12 +1221,12 @@ def perform_xlint(
|
||||
)
|
||||
warn_cnt += 1
|
||||
|
||||
print "\n"
|
||||
print "------------------------------------------"
|
||||
print "VALIDATION SUMMARY: {err} Errors {warn} Warnings".format(
|
||||
print("\n")
|
||||
print("------------------------------------------")
|
||||
print("VALIDATION SUMMARY: {err} Errors {warn} Warnings".format(
|
||||
err=err_cnt,
|
||||
warn=warn_cnt
|
||||
)
|
||||
))
|
||||
|
||||
if err_cnt > 0:
|
||||
print(
|
||||
@@ -1239,7 +1240,7 @@ def perform_xlint(
|
||||
"your courseware before importing"
|
||||
)
|
||||
else:
|
||||
print "This course can be imported successfully."
|
||||
print("This course can be imported successfully.")
|
||||
|
||||
return err_cnt
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import json
|
||||
import unittest
|
||||
|
||||
@@ -178,7 +179,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
|
||||
modules['cond_module'].save()
|
||||
modules['source_module'].is_attempted = "false"
|
||||
ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
|
||||
print "ajax: ", ajax
|
||||
print("ajax: ", ajax)
|
||||
fragments = ajax['fragments']
|
||||
self.assertFalse(any(['This is a secret' in item['content'] for item in fragments]))
|
||||
|
||||
@@ -186,7 +187,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
|
||||
modules['source_module'].is_attempted = "true"
|
||||
ajax = json.loads(modules['cond_module'].handle_ajax('', ''))
|
||||
modules['cond_module'].save()
|
||||
print "post-attempt ajax: ", ajax
|
||||
print("post-attempt ajax: ", ajax)
|
||||
fragments = ajax['fragments']
|
||||
self.assertTrue(any(['This is a secret' in item['content'] for item in fragments]))
|
||||
|
||||
@@ -232,7 +233,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
|
||||
def get_course(self, name):
|
||||
"""Get a test course by directory name. If there's more than one, error."""
|
||||
print "Importing {0}".format(name)
|
||||
print("Importing {0}".format(name))
|
||||
|
||||
modulestore = XMLModuleStore(DATA_DIR, source_dirs=[name])
|
||||
courses = modulestore.get_courses()
|
||||
@@ -243,11 +244,11 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
def test_conditional_module(self):
|
||||
"""Make sure that conditional module works"""
|
||||
|
||||
print "Starting import"
|
||||
print("Starting import")
|
||||
course = self.get_course('conditional_and_poll')
|
||||
|
||||
print "Course: ", course
|
||||
print "id: ", course.id
|
||||
print("Course: ", course)
|
||||
print("id: ", course.id)
|
||||
|
||||
def inner_get_module(descriptor):
|
||||
if isinstance(descriptor, BlockUsageLocator):
|
||||
@@ -269,13 +270,13 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
self.test_system.get_module = inner_get_module
|
||||
|
||||
module = inner_get_module(location)
|
||||
print "module: ", module
|
||||
print "module children: ", module.get_children()
|
||||
print "module display items (children): ", module.get_display_items()
|
||||
print("module: ", module)
|
||||
print("module children: ", module.get_children())
|
||||
print("module display items (children): ", module.get_display_items())
|
||||
|
||||
html = module.render(STUDENT_VIEW).content
|
||||
print "html type: ", type(html)
|
||||
print "html: ", html
|
||||
print("html type: ", type(html))
|
||||
print("html: ", html)
|
||||
html_expect = module.xmodule_runtime.render_template(
|
||||
'conditional_ajax.html',
|
||||
{
|
||||
@@ -288,11 +289,11 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
self.assertEqual(html, html_expect)
|
||||
|
||||
gdi = module.get_display_items()
|
||||
print "gdi=", gdi
|
||||
print("gdi=", gdi)
|
||||
|
||||
ajax = json.loads(module.handle_ajax('', ''))
|
||||
module.save()
|
||||
print "ajax: ", ajax
|
||||
print("ajax: ", ajax)
|
||||
fragments = ajax['fragments']
|
||||
self.assertFalse(any(['This is a secret' in item['content'] for item in fragments]))
|
||||
|
||||
@@ -304,7 +305,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
|
||||
|
||||
ajax = json.loads(module.handle_ajax('', ''))
|
||||
module.save()
|
||||
print "post-attempt ajax: ", ajax
|
||||
print("post-attempt ajax: ", ajax)
|
||||
fragments = ajax['fragments']
|
||||
self.assertTrue(any(['This is a secret' in item['content'] for item in fragments]))
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests the course modules and their functions"""
|
||||
from __future__ import print_function
|
||||
import ddt
|
||||
import unittest
|
||||
from datetime import datetime, timedelta
|
||||
@@ -214,7 +215,7 @@ class IsNewCourseTestCase(unittest.TestCase):
|
||||
for a, b, assertion in dates:
|
||||
a_score = get_dummy_course(start=a[0], announcement=a[1], advertised_start=a[2]).sorting_score
|
||||
b_score = get_dummy_course(start=b[0], announcement=b[1], advertised_start=b[2]).sorting_score
|
||||
print "Comparing %s to %s" % (a, b)
|
||||
print("Comparing %s to %s" % (a, b))
|
||||
assertion(a_score, b_score)
|
||||
|
||||
start_advertised_settings = [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""
|
||||
Tests of XML export
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import ddt
|
||||
import lxml.etree
|
||||
@@ -33,7 +34,7 @@ def strip_filenames(descriptor):
|
||||
"""
|
||||
Recursively strips 'filename' from all children's definitions.
|
||||
"""
|
||||
print "strip filename from {desc}".format(desc=text_type(descriptor.location))
|
||||
print("strip filename from {desc}".format(desc=text_type(descriptor.location)))
|
||||
if descriptor._field_data.has(descriptor, 'filename'):
|
||||
descriptor._field_data.delete(descriptor, 'filename')
|
||||
|
||||
@@ -95,12 +96,12 @@ class RoundTripTestCase(unittest.TestCase):
|
||||
""").strip()
|
||||
|
||||
root_dir = path(self.temp_dir)
|
||||
print "Copying test course to temp dir {0}".format(root_dir)
|
||||
print("Copying test course to temp dir {0}".format(root_dir))
|
||||
|
||||
data_dir = path(DATA_DIR)
|
||||
shutil.copytree(data_dir / course_dir, root_dir / course_dir)
|
||||
|
||||
print "Starting import"
|
||||
print("Starting import")
|
||||
initial_import = XMLModuleStore(root_dir, source_dirs=[course_dir], xblock_mixins=(XModuleMixin,))
|
||||
|
||||
courses = initial_import.get_courses()
|
||||
@@ -109,7 +110,7 @@ class RoundTripTestCase(unittest.TestCase):
|
||||
|
||||
# export to the same directory--that way things like the custom_tags/ folder
|
||||
# will still be there.
|
||||
print "Starting export"
|
||||
print("Starting export")
|
||||
file_system = OSFS(root_dir)
|
||||
initial_course.runtime.export_fs = file_system.makedir(course_dir, recreate=True)
|
||||
root = lxml.etree.Element('root')
|
||||
@@ -118,14 +119,14 @@ class RoundTripTestCase(unittest.TestCase):
|
||||
with initial_course.runtime.export_fs.open('course.xml', 'wb') as course_xml:
|
||||
lxml.etree.ElementTree(root).write(course_xml, encoding='utf-8')
|
||||
|
||||
print "Starting second import"
|
||||
print("Starting second import")
|
||||
second_import = XMLModuleStore(root_dir, source_dirs=[course_dir], xblock_mixins=(XModuleMixin,))
|
||||
|
||||
courses2 = second_import.get_courses()
|
||||
self.assertEquals(len(courses2), 1)
|
||||
exported_course = courses2[0]
|
||||
|
||||
print "Checking course equality"
|
||||
print("Checking course equality")
|
||||
|
||||
# HACK: filenames change when changing file formats
|
||||
# during imports from old-style courses. Ignore them.
|
||||
@@ -136,15 +137,15 @@ class RoundTripTestCase(unittest.TestCase):
|
||||
self.assertEquals(initial_course.id, exported_course.id)
|
||||
course_id = initial_course.id
|
||||
|
||||
print "Checking key equality"
|
||||
print("Checking key equality")
|
||||
self.assertItemsEqual(
|
||||
initial_import.modules[course_id].keys(),
|
||||
second_import.modules[course_id].keys()
|
||||
)
|
||||
|
||||
print "Checking module equality"
|
||||
print("Checking module equality")
|
||||
for location in initial_import.modules[course_id].keys():
|
||||
print("Checking", location)
|
||||
print(("Checking", location))
|
||||
self.assertTrue(blocks_are_equivalent(
|
||||
initial_import.modules[course_id][location],
|
||||
second_import.modules[course_id][location]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
import datetime
|
||||
from tempfile import mkdtemp
|
||||
|
||||
@@ -73,7 +74,7 @@ class BaseCourseTestCase(TestCase):
|
||||
|
||||
def get_course(self, name):
|
||||
"""Get a test course by directory name. If there's more than one, error."""
|
||||
print "Importing {0}".format(name)
|
||||
print("Importing {0}".format(name))
|
||||
|
||||
modulestore = XMLModuleStore(
|
||||
DATA_DIR,
|
||||
@@ -203,7 +204,7 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
Checks to make sure that metadata inheritance on a course descriptor is respected.
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
print(descriptor, descriptor._field_data)
|
||||
print((descriptor, descriptor._field_data))
|
||||
self.assertEqual(descriptor.due, ImportTestCase.date.from_json(from_date_string))
|
||||
|
||||
# Check that the child inherits due correctly
|
||||
@@ -222,7 +223,7 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
descriptor.add_xml_to_node(node)
|
||||
|
||||
# Check that the exported xml is just a pointer
|
||||
print("Exported xml:", etree.tostring(node))
|
||||
print(("Exported xml:", etree.tostring(node)))
|
||||
self.assertTrue(is_pointer_tag(node))
|
||||
# but it's a special case course pointer
|
||||
self.assertEqual(node.attrib['course'], COURSE)
|
||||
@@ -441,22 +442,22 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
"""]
|
||||
|
||||
for xml_str in yes:
|
||||
print "should be True for {0}".format(xml_str)
|
||||
print("should be True for {0}".format(xml_str))
|
||||
self.assertTrue(is_pointer_tag(etree.fromstring(xml_str)))
|
||||
|
||||
for xml_str in no:
|
||||
print "should be False for {0}".format(xml_str)
|
||||
print("should be False for {0}".format(xml_str))
|
||||
self.assertFalse(is_pointer_tag(etree.fromstring(xml_str)))
|
||||
|
||||
def test_metadata_inherit(self):
|
||||
"""Make sure that metadata is inherited properly"""
|
||||
|
||||
print "Starting import"
|
||||
print("Starting import")
|
||||
course = self.get_course('toy')
|
||||
|
||||
def check_for_key(key, node, value):
|
||||
"recursive check for presence of key"
|
||||
print "Checking {0}".format(text_type(node.location))
|
||||
print("Checking {0}".format(text_type(node.location)))
|
||||
self.assertEqual(getattr(node, key), value)
|
||||
for c in node.get_children():
|
||||
check_for_key(key, c, value)
|
||||
@@ -525,17 +526,17 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
def test_colon_in_url_name(self):
|
||||
"""Ensure that colons in url_names convert to file paths properly"""
|
||||
|
||||
print "Starting import"
|
||||
print("Starting import")
|
||||
# Not using get_courses because we need the modulestore object too afterward
|
||||
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
|
||||
courses = modulestore.get_courses()
|
||||
self.assertEquals(len(courses), 1)
|
||||
course = courses[0]
|
||||
|
||||
print "course errors:"
|
||||
print("course errors:")
|
||||
for (msg, err) in modulestore.get_course_errors(course.id):
|
||||
print msg
|
||||
print err
|
||||
print(msg)
|
||||
print(err)
|
||||
|
||||
chapters = course.get_children()
|
||||
self.assertEquals(len(chapters), 5)
|
||||
@@ -543,12 +544,12 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
ch2 = chapters[1]
|
||||
self.assertEquals(ch2.url_name, "secret:magic")
|
||||
|
||||
print "Ch2 location: ", ch2.location
|
||||
print("Ch2 location: ", ch2.location)
|
||||
|
||||
also_ch2 = modulestore.get_item(ch2.location)
|
||||
self.assertEquals(ch2, also_ch2)
|
||||
|
||||
print "making sure html loaded"
|
||||
print("making sure html loaded")
|
||||
loc = course.id.make_usage_key('html', 'secret:toylab')
|
||||
html = modulestore.get_item(loc)
|
||||
self.assertEquals(html.display_name, "Toy lab")
|
||||
@@ -560,13 +561,13 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
loaded because of unicode filenames, there are appropriate
|
||||
exceptions/errors to that effect."""
|
||||
|
||||
print "Starting import"
|
||||
print("Starting import")
|
||||
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode'])
|
||||
courses = modulestore.get_courses()
|
||||
self.assertEquals(len(courses), 1)
|
||||
course = courses[0]
|
||||
|
||||
print "course errors:"
|
||||
print("course errors:")
|
||||
|
||||
# Expect to find an error/exception about characters in "®esources"
|
||||
expect = "InvalidKeyError"
|
||||
@@ -602,7 +603,7 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
for i in (2, 3):
|
||||
video = sections[i]
|
||||
# Name should be 'video_{hash}'
|
||||
print "video {0} url_name: {1}".format(i, video.url_name)
|
||||
print("video {0} url_name: {1}".format(i, video.url_name))
|
||||
self.assertEqual(len(video.url_name), len('video_') + 12)
|
||||
|
||||
def test_poll_and_conditional_import(self):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Tests stringify functions used in xmodule html
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from lxml import etree
|
||||
from openedx.core.lib.tests import attr
|
||||
from xmodule.stringify import stringify_children
|
||||
@@ -38,8 +39,8 @@ def test_stringify_again():
|
||||
xml = etree.fromstring(html)
|
||||
out = stringify_children(xml)
|
||||
|
||||
print "output:"
|
||||
print out
|
||||
print("output:")
|
||||
print(out)
|
||||
|
||||
# Tracking strange content repeating bug
|
||||
# Should appear once
|
||||
|
||||
Reference in New Issue
Block a user