def test_memoryerror(self):
    lines = linecache.getlines(FILENAME)
    self.assertTrue(lines)

    def raise_memoryerror(*args, **kwargs):
        raise MemoryError
    with support.swap_attr(linecache, 'updatecache', raise_memoryerror):
        lines2 = linecache.getlines(FILENAME)
    self.assertEqual(lines2, lines)
    linecache.clearcache()
    with support.swap_attr(linecache, 'updatecache', raise_memoryerror):
        lines3 = linecache.getlines(FILENAME)
    self.assertEqual(lines3, [])
    self.assertEqual(linecache.getlines(FILENAME), lines)
def test_memoryerror(self):
    lines = linecache.getlines(FILENAME)
    self.assertTrue(lines)

    def raise_memoryerror(*args, **kwargs):
        raise MemoryError
    with support.swap_attr(linecache, 'updatecache', raise_memoryerror):
        lines2 = linecache.getlines(FILENAME)
    self.assertEqual(lines2, lines)
    linecache.clearcache()
    with support.swap_attr(linecache, 'updatecache', raise_memoryerror):
        lines3 = linecache.getlines(FILENAME)
    self.assertEqual(lines3, [])
    self.assertEqual(linecache.getlines(FILENAME), lines)