diff options
| author | Emanuele Rocca <ema@debian.org> | 2008-10-06 10:31:30 +0200 |
|---|---|---|
| committer | Emanuele Rocca <ema@debian.org> | 2008-10-06 10:31:30 +0200 |
| commit | 754744630ff6228029cd025074dc0cfe3de08495 (patch) | |
| tree | f97bb12295ac5b375f72b588f4b7f5eb42e7fee0 /tests | |
| parent | 5363fda9e7ebdc4dd191183ece2e6e070d68d716 (diff) | |
| download | python-apt-754744630ff6228029cd025074dc0cfe3de08495.tar.gz | |
Test case and proposed fix for Debian bug #497049
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/getcache_mem_corruption.py | 27 |
1 files changed, 20 insertions, 7 deletions
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() |
