I have this module installed by me in my virtual env using pip install
: concurrent_log_handler
(best thing since sliced bread, by the way).
I want to create a test which will run the following app code:
try:
from concurrent_log_handler import ConcurrentRotatingFileHandler
except BaseException as e:
print(f'e was |{e}|', file=sys.stderr)
... and want the framework to find that this module concurrent_log_handler is "not available", and thus print out for the user a suitable message like "you have to run 'pip install concurrent_log_handler'".
The thing is, this is not the same as being present in sys.modules
: it is only after the above code that you find that a key "concurrent_log_handler" is now present in sys.modules
.
Is there some sort of dict
somewhere of "modules which have been installed but not yet imported"? If so, I surmise that deleting the key from that dict
might do the trick...