I've written a Python program that makes use of the resource module on Unix systems to do some timing operations, but falls back to using the time module on Windows (since the resource module is unavailable). The code looks something along the lines of this:
try:
    import resource
except ImportError:
    import time
    def fn():
        # Implementation using the time module
else:
    def fn():
        # Implementation using the resource module
However, my tests currently only ever execute function in the else block, since the resource module is always available on Linux. Is there a way to simulate the unavailability of built-in modules such that I can test the time-based function as well? I've looked through the mock documentation but couldn't find anything about this specifically.
 
     
    