summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2012-06-22 10:36:30 +0200
committerJulian Andres Klode <jak@debian.org>2012-06-22 10:36:30 +0200
commit653444b666238fb1a991821e8b0cce1a9cb2513f (patch)
treea36501790d58ef6eee1cbeec1a91255727d24f0e /tests
parent82c433f15822cc65896e046343d8e781141d62d2 (diff)
downloadpython-apt-653444b666238fb1a991821e8b0cce1a9cb2513f.tar.gz
* tests:
- Fix new tests from Sebastian to work with Python 2.6
Diffstat (limited to 'tests')
-rw-r--r--tests/test_auth.py14
-rw-r--r--tests/test_lp659438.py4
2 files changed, 15 insertions, 3 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index f975c670..99c40db5 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -7,7 +7,7 @@ import tempfile
import time
import unittest
-if sys.version_info.major > 2:
+if sys.version_info[0] > 2:
from http.server import HTTPServer
from http.server import SimpleHTTPRequestHandler as HTTPRequestHandler
else:
@@ -107,6 +107,18 @@ class TestAuthKeys(unittest.TestCase):
"""Test handling of keys for signed repositories."""
+ if sys.version_info[0] == 2 and sys.version_info[1] < 7:
+ def addCleanup(self, function, *args, **kwds):
+ try:
+ self.cleanup.append(lambda: function(*args, **kwds))
+ except AttributeError:
+ self.cleanup = [lambda: function(*args, **kwds)]
+
+ def tearDown(self):
+ for f in self.cleanup:
+ f()
+ self.cleanup = []
+
def setUp(self):
# reset any config manipulations done in the individual tests
apt_pkg.init_config()
diff --git a/tests/test_lp659438.py b/tests/test_lp659438.py
index 01edf3bd..4564f0f6 100644
--- a/tests/test_lp659438.py
+++ b/tests/test_lp659438.py
@@ -39,8 +39,7 @@ class RegressionTestCase(unittest.TestCase):
def setUp(self):
apt_pkg.init_config()
- chroot_path = tempfile.mkdtemp()
- self.addCleanup(lambda: shutil.rmtree(chroot_path))
+ self.chroot_path = chroot_path = tempfile.mkdtemp()
# Create a damaged status file
self.cache = apt.cache.Cache(rootdir=chroot_path)
with open(apt_pkg.config.find_file("Dir::State::status"),
@@ -62,6 +61,7 @@ Version: 3.6.9+build1+nobinonly-0ubuntu1""")
# this resets the rootdir apt_pkg.config to ensure it does not
# "pollute" the later tests
cache = apt.cache.Cache(rootdir="/")
+ shutil.rmtree(self.chroot_path)
def test_survive_reqreinst(self):
"""Test that we survive a package in require reinstallation state"""