def testInstall_filterSysPath(self): emptyDir = tempfile.mkdtemp() try: dirs = ["", "/somewhere/python27.zip", DIR1, emptyDir] q.install("noCache filterDirs", dirs) finally: os.rmdir(emptyDir) self.assertListEqual(dirs, ["", "/somewhere/python27.zip", DIR1])
def testImports(self): q.install() import tabnanny sys.modules.pop("email", None) import email # a package sys.modules.pop("email.message", None) import email.message self.assertRaises(ImportError, __import__, "NoSuchModule")
def testUninstall(self): self.assertFalse(hasattr(sys, "quickimport_cache")) q.install("off") self.assertFalse(hasattr(sys, "quickimport_cache")) self.assertListEqual(self.origSysPath, sys.path) self.assertListEqual(self.origPathHooks, sys.path_hooks) self.assertDictEqual(self.origPIC, sys.path_importer_cache) q.install() self.assertTrue(hasattr(sys, "quickimport_cache")) self.assertTrue(sys.quickimport_cache[q.AUTOCHACHE_KEY]) self.assertListEqual(self.origSysPath, sys.path) q.uninstall() self.assertFalse(hasattr(sys, "quickimport_cache")) self.assertListEqual(self.origSysPath, sys.path) self.assertListEqual(self.origPathHooks, sys.path_hooks) self.assertDictEqual(sys.path_importer_cache, {})