def test_memory_maps(self): # XXX: on Python 2, using ctypes.CDLL with a unicode path # opens a message box which blocks the test run. with copyload_shared_lib(dst_prefix=self.funky_name) as funky_path: def normpath(p): return os.path.realpath(os.path.normcase(p)) libpaths = [normpath(x.path) for x in psutil.Process().memory_maps()] # ...just to have a clearer msg in case of failure libpaths = [x for x in libpaths if TESTFILE_PREFIX in x] self.assertIn(normpath(funky_path), libpaths) for path in libpaths: self.assertIsInstance(path, str)
def test_memory_maps(self): p = psutil.Process() ext = ".so" if POSIX else ".dll" old = [ x.path for x in p.memory_maps() if os.path.normcase(x.path).endswith(ext) ][0] try: new = os.path.normcase( copyload_shared_lib(old, dst_prefix=self.funky_name)) except UnicodeEncodeError: if PY3: raise else: raise unittest.SkipTest("ctypes can't handle unicode") newpaths = [os.path.normcase(x.path) for x in p.memory_maps()] self.assertIn(new, newpaths)