I think using Mock is a good approach.
For example you have some dangerous function, which is doing something and then should return something.
If your program relay on the return value, you can Mock the function to get the return prevent something happening in the background.
Example:
For example you have some dangerous function, which is doing something and then should return something.
If your program relay on the return value, you can Mock the function to get the return prevent something happening in the background.
Example:
def delete_temp(): """ Example-Function to delete something """ print('Deleting everything... oh nooooo') try: shutil.rmtree('/qwertzuiop') except Exception as e: print(e) return False return TrueInstead of deleting the name of the function or changing the function, you can mock it.
from unittests.mock import Mock class Delete_Temp(Mock): def __call__(self): return True delete_temp = Delete_Temp() print(delete_temp())Then you can do also crazy things like:
>>> delete_temp.my_mock.is_super() True
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!