summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-02-13 16:41:39 +0100
committerJulian Andres Klode <jak@debian.org>2010-02-13 16:41:39 +0100
commitdadba850a99f4ae87ac0a7a89b60bae849d76306 (patch)
treee65f89369a72fec4e9a63e579ccc526380e4db18 /tests
parentf594f8f2b8e90717ccbdcc3d17ada3c7d0e9163a (diff)
downloadpython-apt-dadba850a99f4ae87ac0a7a89b60bae849d76306.tar.gz
* tests:
- Fix aptsources tests to use local data files if available.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_aptsources.py12
-rw-r--r--tests/test_aptsources_ports.py6
2 files changed, 13 insertions, 5 deletions
diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py
index 0ae05bf3..0f7f078b 100644
--- a/tests/test_aptsources.py
+++ b/tests/test_aptsources.py
@@ -16,6 +16,10 @@ class TestAptSources(unittest.TestCase):
apt_pkg.init_system()
apt_pkg.config.set("Dir::Etc", os.getcwd())
apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx")
+ if os.path.exists("../build/data/templates"):
+ self.templates = os.path.abspath("../build/data/templates")
+ else:
+ self.templates = "/usr/share/python-apt/templates/"
def testIsMirror(self):
"""aptsources: Test mirror detection."""
@@ -30,7 +34,7 @@ class TestAptSources(unittest.TestCase):
"""aptsources: Test sources.list parsing."""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list")
- sources = aptsources.sourceslist.SourcesList()
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
self.assertEqual(len(sources.list), 6)
# test load
sources.list = []
@@ -41,7 +45,7 @@ class TestAptSources(unittest.TestCase):
"""aptsources: Test additions to sources.list"""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list")
- sources = aptsources.sourceslist.SourcesList()
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
# test to add something that is already there (main)
before = copy.deepcopy(sources)
sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
@@ -91,7 +95,7 @@ class TestAptSources(unittest.TestCase):
"""aptsources: Test matcher"""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list.testDistribution")
- sources = aptsources.sourceslist.SourcesList()
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
distro = aptsources.distro.get_distro()
distro.get_sources(sources)
# test if all suits of the current distro were detected correctly
@@ -104,7 +108,7 @@ class TestAptSources(unittest.TestCase):
"""aptsources: Test distribution detection."""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list.testDistribution")
- sources = aptsources.sourceslist.SourcesList()
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
distro = aptsources.distro.get_distro()
distro.get_sources(sources)
# test if all suits of the current distro were detected correctly
diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py
index f837585b..991b532a 100644
--- a/tests/test_aptsources_ports.py
+++ b/tests/test_aptsources_ports.py
@@ -18,11 +18,15 @@ class TestAptSourcesPorts(unittest.TestCase):
apt_pkg.config.set("Dir::Etc",
os.path.abspath("data/aptsources_ports"))
apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx")
+ 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()
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc",
"8.04")
distro.get_sources(sources)