def test_checkcache(self):
    getline = linecache.getline
    source_name = (support.TESTFN + '.py')
    self.addCleanup(support.unlink, source_name)
    with open(source_name, 'w') as source:
        source.write(SOURCE_1)
    getline(source_name, 1)
    source_list = []
    with open(source_name) as source:
        for (index, line) in enumerate(source):
            self.assertEqual(line, getline(source_name, (index + 1)))
            source_list.append(line)
    with open(source_name, 'w') as source:
        source.write(SOURCE_2)
    linecache.checkcache('dummy')
    for (index, line) in enumerate(source_list):
        self.assertEqual(line, getline(source_name, (index + 1)))
    linecache.checkcache(source_name)
    with open(source_name) as source:
        for (index, line) in enumerate(source):
            self.assertEqual(line, getline(source_name, (index + 1)))
            source_list.append(line)
def test_checkcache(self):
    getline = linecache.getline
    source_name = (support.TESTFN + '.py')
    self.addCleanup(support.unlink, source_name)
    with open(source_name, 'w') as source:
        source.write(SOURCE_1)
    getline(source_name, 1)
    source_list = []
    with open(source_name) as source:
        for (index, line) in enumerate(source):
            self.assertEqual(line, getline(source_name, (index + 1)))
            source_list.append(line)
    with open(source_name, 'w') as source:
        source.write(SOURCE_2)
    linecache.checkcache('dummy')
    for (index, line) in enumerate(source_list):
        self.assertEqual(line, getline(source_name, (index + 1)))
    linecache.checkcache(source_name)
    with open(source_name) as source:
        for (index, line) in enumerate(source):
            self.assertEqual(line, getline(source_name, (index + 1)))
            source_list.append(line)