From 754744630ff6228029cd025074dc0cfe3de08495 Mon Sep 17 00:00:00 2001 From: Emanuele Rocca Date: Mon, 6 Oct 2008 10:31:30 +0200 Subject: Test case and proposed fix for Debian bug #497049 --- tests/getcache_mem_corruption.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/getcache_mem_corruption.py b/tests/getcache_mem_corruption.py index e127f66e..42e9af00 100644 --- a/tests/getcache_mem_corruption.py +++ b/tests/getcache_mem_corruption.py @@ -1,11 +1,24 @@ #!/usr/bin/python +import apt import apt_pkg import re -apt_pkg.InitConfig() -apt_pkg.InitSystem() -apt_cache = apt_pkg.GetCache() -# wrong -apt_depcache = apt_pkg.GetCache(apt_cache) -# correct: apt_depcache = apt_pkg.GetDepCache(apt_cache) -re.compile('a') +import unittest + +class TestGetCache(unittest.TestCase): + + def setUp(self): + apt_pkg.InitConfig() + apt_pkg.InitSystem() + + def testWrongInvocation(self): + # wrongly invoke GetCache() rather than GetDepCache() + apt_cache = apt_pkg.GetCache() + self.assertRaises(ValueError, apt_pkg.GetCache, apt_cache) + + def testProperInvocation(self): + apt_cache = apt_pkg.GetCache(apt.progress.OpTextProgress()) + apt_depcache = apt_pkg.GetDepCache(apt_cache) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3