From 653444b666238fb1a991821e8b0cce1a9cb2513f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 22 Jun 2012 10:36:30 +0200 Subject: * tests: - Fix new tests from Sebastian to work with Python 2.6 --- tests/test_auth.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/test_auth.py') 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() -- cgit v1.2.3