def test_create_file(self): size = 1024 path = guid() try: mm = SharedMmap(path, size, create=True) mm.close() self.assertTrue(os.path.exists(path)) self.assertEqual(os.stat(path).st_size, size) finally: _nuke(path)
def test_close_file(self): path = guid() self.to_nuke.append(path) data = guid() mm = SharedMmap(path, len(data), create=True) assert mm.closed is False mm.close() assert mm.closed is True # idempotent mm.close() assert mm.closed is True self.assertRaises(IOError, mm.read, 4) self.assertRaises(IOError, mm.write, 'bazqux') self.assertRaises(IOError, mm.seek, 0) self.assertRaises(IOError, mm.flush)