예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)