I am running a computer programming course that uses Sage and Python, however, I am not an expert programmer myself in Python. (FYI Sage is an alternative kernel to Python 3, which has a number of efficient packages for abstract algebra compiled in). I often find myself wanting to assign the students to program some task which Sage can already do built-in to the kernel, and I need to make sure they are not simply calling the built-in functionality. I am using a program called nbgrader which runs their code and asserts various facts about it to test that it is computing correctly, and can generally run any python command imaginable on the function, it then tests a series of assert commands and if they all pass then they get full credit for the problem.
I have tried to follow tutorials which have me delete the built-in function, or use unit test and mocking to otherwise subvert it. However, I get errors like:
can't set attributes of built-in/extension type 'sage.structure.element.Matrix when I try just to delete the built-in matrix multiplication functionality. Similar errors when I try to mock it. Is there some clever way for me to either delete or otherwise subvert a built-in function so that it throws an error if they attempt to call it? Or failing that, can I get python to print to a string a log of all function calls, e.g. so that sage.structure.element.Matrix.__mult__ would show up in this string if their function when run on some example uses the built-in matrix multiplication functionality?