BOM Project Capa Module Python3 Compatibility
Python3 RNG produces different results as compared to python2 In capa problems we save seed value and generate random state using the seed. Python3 random generates a different state as compared to python2. Thats why using random2 library to make state genration consistent in both python versions.
This commit is contained in:
@@ -19,7 +19,7 @@ import inspect
|
||||
import json
|
||||
import logging
|
||||
import numbers
|
||||
import random
|
||||
import random2 as random
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
@@ -8,7 +8,7 @@ from __future__ import absolute_import
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import random2 as random
|
||||
import textwrap
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function
|
||||
|
||||
import textwrap
|
||||
import unittest
|
||||
import six
|
||||
|
||||
from capa.responsetypes import LoncapaProblemError
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
@@ -59,10 +58,7 @@ class CapaShuffleTest(unittest.TestCase):
|
||||
response = list(problem.responders.values())[0]
|
||||
self.assertFalse(response.has_mask())
|
||||
self.assertTrue(response.has_shuffle())
|
||||
if six.PY2:
|
||||
self.assertEqual(response.unmask_order(), ['choice_0', 'choice_aaa', 'choice_1', 'choice_ddd'])
|
||||
else:
|
||||
self.assertEqual(response.unmask_order(), ['choice_1', 'choice_aaa', 'choice_0', 'choice_ddd'])
|
||||
self.assertEqual(response.unmask_order(), ['choice_0', 'choice_aaa', 'choice_1', 'choice_ddd'])
|
||||
|
||||
def test_shuffle_different_seed(self):
|
||||
xml_str = textwrap.dedent("""
|
||||
|
||||
@@ -138,6 +138,7 @@ pytz # Time zone information database
|
||||
PyYAML # Used to parse XModule resource templates
|
||||
redis==2.10.6 # celery task broker
|
||||
requests-oauthlib # Simplifies use of OAuth via the requests library, used for CCX and LTI
|
||||
random2
|
||||
rules # Django extension for rules-based authorization checks
|
||||
sailthru-client==2.2.3 # For Sailthru integration
|
||||
Shapely # Geometry library, used for image click regions in capa
|
||||
|
||||
@@ -207,6 +207,7 @@ python3-saml==1.5.0
|
||||
pytz==2019.2
|
||||
pyuca==1.1
|
||||
pyyaml==5.1.2
|
||||
random2==1.0.1
|
||||
recommender-xblock==1.4.4
|
||||
redis==2.10.6
|
||||
requests-oauthlib==1.1.0
|
||||
|
||||
@@ -279,6 +279,7 @@ pytz==2019.2
|
||||
pyuca==1.1
|
||||
pyyaml==5.1.2
|
||||
radon==4.0.0
|
||||
random2==1.0.1
|
||||
recommender-xblock==1.4.4
|
||||
recommonmark==0.6.0
|
||||
redis==2.10.6
|
||||
|
||||
@@ -270,6 +270,7 @@ pytz==2019.2
|
||||
pyuca==1.1
|
||||
pyyaml==5.1.2
|
||||
radon==4.0.0
|
||||
random2==1.0.1
|
||||
recommender-xblock==1.4.4
|
||||
redis==2.10.6
|
||||
requests-oauthlib==1.1.0
|
||||
|
||||
Reference in New Issue
Block a user