diff options
| -rw-r--r-- | tests/old/getcache_mem_corruption.py | 24 | ||||
| -rw-r--r-- | tests/test_cache_invocation.py | 32 |
2 files changed, 32 insertions, 24 deletions
diff --git a/tests/old/getcache_mem_corruption.py b/tests/old/getcache_mem_corruption.py deleted file mode 100644 index c6e5ff80..00000000 --- a/tests/old/getcache_mem_corruption.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/python -import apt -import apt_pkg -import re - -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.Cache() - self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) - - def testProperInvocation(self): - apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress()) - apt_depcache = apt_pkg.DepCache(apt_cache) - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py new file mode 100644 index 00000000..9d34891d --- /dev/null +++ b/tests/test_cache_invocation.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +import apt_pkg + +import unittest + +class TestCache(unittest.TestCase): + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + + def test_wrong_invocation(self): + """wrongly invoke GetCache() rather than GetDepCache().""" + apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + if apt_pkg._COMPAT_0_7: + self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) + self.assertRaises(ValueError, apt_pkg.Cache, + apt_pkg.AcquireProgress()) + self.assertRaises(ValueError, apt_pkg.Cache, 0) + else: + self.assertRaises(TypeError, apt_pkg.Cache, apt_cache) + self.assertRaises(TypeError, apt_pkg.Cache, + apt_pkg.AcquireProgress()) + self.assertRaises(TypeError, apt_pkg.Cache, 0) + + def test_proper_invocation(self): + """Invoke it the right way.""" + apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) + apt_depcache = apt_pkg.DepCache(apt_cache) + +if __name__ == "__main__": + unittest.main() |
