blob: b625b8c4dea34e07ded28df46437488b0ad5e7b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/env python
import os
import unittest
import tempfile
import apt_pkg
import aptsources.sourceslist
import aptsources.distro
class TestAptSourcesPorts(unittest.TestCase):
"""Test aptsources on ports.ubuntu.com."""
def setUp(self):
apt_pkg.init_config()
apt_pkg.init_system()
apt_pkg.config.set("APT::Architecture", "powerpc")
apt_pkg.config.set("Dir::Etc",
os.path.abspath("data/aptsources_ports"))
apt_pkg.config.set("Dir::Etc::sourceparts", tempfile.mkdtemp())
if os.path.exists("../build/data/templates"):
self.templates = os.path.abspath("../build/data/templates")
else:
self.templates = "/usr/share/python-apt/templates/"
def testMatcher(self):
"""aptsources_ports: Test matcher."""
apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list")
sources = aptsources.sourceslist.SourcesList(True, self.templates)
distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc",
"8.04")
distro.get_sources(sources)
# test if all suits of the current distro were detected correctly
for s in sources:
if not s.line.strip() or s.line.startswith("#"):
continue
if not s.template:
self.fail("source entry '%s' has no matcher" % s)
if __name__ == "__main__":
unittest.main()
|