In OpenAI's Gymnasium environments, there's a render() method that at the end calls pygame.display.flip() to draw on the screen. I'm trying to prevent the render() method from calling the pygame.display.flip() method without changing the definition of the render() method. Is that possible in any way?
If this is for testing environment, then you might be able to use unittest.mock.patch to disable the call.
If you want to do this is a production code things gets a bit more tricky, but since it's open source, what you can do is just build your own version of the library.
It is possible to use unittest.mock for monkey patching outside the context of unit tests, it's not very recommendable, but if you know what you're doing, we're all consenting adults here.
Can I prevent a method called by another method from being called without changing the definition of the original method?