From a21604afdb6e42f527f26802a1fc23781a7c277a Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Fri, 27 Sep 2019 11:39:34 +0500 Subject: [PATCH] BOM-613 Made all tests py3 compatible. --- common/lib/capa/capa/tests/test_responsetypes.py | 5 ++++- common/lib/symmath/symmath/formula.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index e132b2c6cf..be9c88c13f 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -5,6 +5,7 @@ Tests of responsetypes from __future__ import absolute_import +import io import json import os import random @@ -1588,6 +1589,8 @@ class NumericalResponseTest(ResponseTest): # pylint: disable=missing-docstring if text == "There was a problem with the staff answer to this problem.": text = "TRANSLATED!" return text + gettext = ugettext + problem.capa_system.i18n = FakeTranslations() with self.assertRaisesRegexp(StudentInputError, "TRANSLATED!"): @@ -2294,7 +2297,7 @@ class CustomResponseTest(ResponseTest): # pylint: disable=missing-docstring # Prove that we can import code from a zipfile passed down to us. # Make a zipfile with one module in it with one function. - zipstring = StringIO() + zipstring = io.BytesIO() zipf = zipfile.ZipFile(zipstring, "w") zipf.writestr("my_helper.py", textwrap.dedent("""\ def seventeen(): diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index 2691853769..37405a2a5b 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -424,7 +424,7 @@ class formula(object): # pre-process the presentation mathml before sending it to snuggletex to convert to content mathml try: - xml = self.preprocess_pmathml(self.expr) + xml = self.preprocess_pmathml(self.expr).decode('utf-8') except Exception as err: # pylint: disable=broad-except log.warning('Err %s while preprocessing; expr=%s', err, self.expr) return "Error! Cannot process pmathml"