BOM fixed remaining capa module issues

BOM-898 fix test_responsetypes.py issues
Updated safe_exec to use random2 library instead of random.
As python3 random generates different results as compared to
python2, which causes a lot of test failures and if we use
python3 random and fix tests it will cause state invalidation
of capa problems, So random2 was uses to make the behaviour same
in python3.

BOM-899 name xrange is not defined
xrange is used in safe_exec and there might be old courses where
this is being used in capa problems. All those tests fail in python3
as this was renamed to range. Used six.moves.xrange so that code
works for python3 and if there is any old code using xrange it
works too.
This commit is contained in:
Ayub khan
2019-10-10 12:36:05 +05:00
parent 4bce520f29
commit e9c4c22e6a
2 changed files with 4 additions and 2 deletions

View File

@@ -21,8 +21,10 @@ from __future__ import absolute_import, division
import os
os.environ["OPENBLAS_NUM_THREADS"] = "1" # See TNL-6456
import random as random_module
import random2 as random_module
import sys
from six.moves import xrange
random = random_module.Random(%r)
random.Random = random_module.Random
sys.modules['random'] = random

View File

@@ -5,7 +5,7 @@ from __future__ import absolute_import
import hashlib
import os
import os.path
import random
import random2 as random
import textwrap
import unittest