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: //home/arjun/python-apt/tests/test_cache_invocation.py
#!/usr/bin/python3
import unittest

import apt_pkg
import testcommon

import apt.progress.base


class TestCache(testcommon.TestCase):
    """Test invocation of apt_pkg.Cache()"""

    def test_wrong_invocation(self):
        """cache_invocation: Test wrong invocation."""
        apt_cache = apt_pkg.Cache(progress=None)

        self.assertRaises(ValueError, apt_pkg.Cache, apt_cache)
        self.assertRaises(
            ValueError, apt_pkg.Cache, apt.progress.base.AcquireProgress()
        )
        self.assertRaises(ValueError, apt_pkg.Cache, 0)

    def test_proper_invocation(self):
        """cache_invocation: Test correct invocation."""
        apt_cache = apt_pkg.Cache(progress=None)
        apt_depcache = apt_pkg.DepCache(apt_cache)
        self.assertNotEqual(apt_depcache, None)


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