From 05b659d926b999015db3c47c7e5335093d9cbfff Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Mar 2010 15:19:14 +0100 Subject: * tests/test_apt_cache.py: - add simple test for basic cache/dependency iteration --- tests/test_apt_cache.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test_apt_cache.py (limited to 'tests/test_apt_cache.py') diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py new file mode 100644 index 00000000..3c2961e1 --- /dev/null +++ b/tests/test_apt_cache.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# +# Copyright (C) 2010 Julian Andres Klode +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Unit tests for verifying the correctness of check_dep, etc in apt_pkg.""" +import unittest + +import apt + + +class TestAptCache(unittest.TestCase): + """ test the apt cache """ + + def testAptCache(self): + """ simple test that iterates all packages and all dependencies """ + cache = apt.Cache() + # number is not meaningful and just need to be "big enough", + # the important bit is the test against __len__ + self.assertTrue(len(cache) > 100) + # go over the cache and all dependencies, just to see if + # that is possible and does not crash + for pkg in cache: + if pkg.candidate: + for or_dep in pkg.candidate.dependencies: + for dep in or_dep.or_dependencies: + name = dep.name + relation = dep.relation + preDepends = dep.pre_depend + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3