def test_bad_stuff(): ''' Cases where IP should not load an assembly for one reason or another. ''' #ensure that users cannot override IP native modules import sys Assert(sys.winver != "HIJACKED") import re Assert(re.compile != "HIJACKED") #ensure corrupted DLLs cannot be loaded try: import fooCORRUPT raise Exception("Corrupted DLL was loaded") except ImportError as e: pass #nothing to do for unmanaged DLLs...if the interpreter has made it #this far, all is well:) #ensure *.exe's cannot take precedence over *.dlls import fooDLLEXE AreEqual(fooDLLEXE.Foo().BAR, 1) #ensure *.exe's are not autoloaded at all! try: import fooEXEONLY raise Exception("*.exe's should not be autoloaded!") except ImportError as e: pass except SystemError as e: print("Work Item #189503") #ensure *.txt's are not autoloaded at all try: import fooTXTDLL raise Exception("*.txt's should not be autoloaded!") except ImportError as e: pass
import re Assert(re.compile != "HIJACKED") #ensure corrupted DLLs cannot be loaded try: import fooCORRUPT raise Exception("Corrupted DLL was loaded") except ImportError, e: pass #nothing to do for unmanaged DLLs...if the interpreter has made it #this far, all is well:) #ensure *.exe's cannot take precedence over *.dlls import fooDLLEXE AreEqual(fooDLLEXE.Foo().BAR, 1) #ensure *.exe's are not autoloaded at all! try: import fooEXEONLY raise Exception("*.exe's should not be autoloaded!") except ImportError, e: pass except SystemError, e: print "Work Item #189503" #ensure *.txt's are not autoloaded at all try: import fooTXTDLL raise Exception("*.txt's should not be autoloaded!") except ImportError, e: