HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/home/arjun/python-apt/tests/test_group.py
import unittest

import apt_pkg
import testcommon


class TestGroup(testcommon.TestCase):
    def setUp(self):
        testcommon.TestCase.setUp(self)
        self.cache = apt_pkg.Cache(progress=None)

    def test_pkgingroup(self):
        """Check that each package belongs to the corresponding group"""
        for pkg in self.cache.packages:
            group = apt_pkg.Group(self.cache, pkg.name)
            assert any(pkg.id == p.id for p in group)

    def test_iteration(self):
        """Check that iteration works correctly."""
        for pkg in self.cache.packages:
            group = apt_pkg.Group(self.cache, pkg.name)

            list(group) == list(group)

    def test_cache_groups(self):
        """group: Iterate over all groups"""
        assert len(list(self.cache.groups)) == self.cache.group_count


if __name__ == "__main__":
    unittest.main()