pythonwhat
pythonwhat copied to clipboard
check_function inside for loop can't find aliases outside
The following works fine:
# solution
import numpy as np
np.random.randint(1, 7)
# sct
Ex().check_function('numpy.random.randint')
The following does not:
# solution
import numpy as np
for x in range(0):
np.random.randint(1, 7)
# sct
Ex().check_for_loop().check_body().check_function('numpy.random.randint')
This is because the mappings of aliases onto their modules are figured out on a per-state basis (instead of once, on the root).
There's a failing test (with the xfail
mark) here.
This is a pretty big bug!!!