diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-07-05 22:06:22 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-07-05 22:06:22 +0300 |
commit | 622812485150fa7864910ee2f710d5aab2fa9e6d (patch) | |
tree | b3bc4fd72bb80e74ba5a60d8b3d47e610dff012e /tests/test_auth.py | |
parent | 798846ab8337471998b0a4d796d6d409453faa7d (diff) | |
parent | fdd173dd444098ed533cbcd541a7f10f228bc47e (diff) | |
download | python-apt-622812485150fa7864910ee2f710d5aab2fa9e6d.tar.gz |
Merge git://anonscm.debian.org/apt/python-apt
Conflicts:
debian/changelog
python/apt_pkgmodule.cc
Diffstat (limited to 'tests/test_auth.py')
-rw-r--r-- | tests/test_auth.py | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py index bc353427..67377363 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -15,17 +15,13 @@ import unittest if sys.version_info[0] > 2: from http.server import HTTPServer from http.server import SimpleHTTPRequestHandler as HTTPRequestHandler + HTTPServer # pyflakes + HTTPRequestHandler # pyflakes else: from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler as HTTPRequestHandler -if sys.version_info[0] == 2 and sys.version_info[1] == 6: - from unittest2 import TestCase -else: - from unittest import TestCase - - import apt_pkg import apt.auth @@ -115,22 +111,10 @@ DHcut3Yey8o= -----END PGP PUBLIC KEY BLOCK-----""" -class TestAuthKeys(TestCase): +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() @@ -215,7 +199,8 @@ class TestAuthKeys(TestCase): def test_add_key_from_keyserver_too_short(self): """Ensure that short keyids are not imported""" with self.assertRaises(apt.auth.AptKeyError): - apt.auth.add_key_from_keyserver("46925553", "hkp://localhost:19191") + apt.auth.add_key_from_keyserver( + "46925553", "hkp://localhost:19191") def test_add_key_from_server_mitm(self): """Verify that the key fingerprint is verified after download""" @@ -227,7 +212,11 @@ class TestAuthKeys(TestCase): "0101010178F7FE5C3E65D8AF8B48AD6246925553", "hkp://localhost:%d" % self.keyserver_port) self.assertTrue( - str(cm.exception).startswith("Fingerprints do not match"), cm.exception) + str(cm.exception).startswith( + "recv from 'hkp://localhost:%d' failed for '%s'" % ( + self.keyserver_port, + "0101010178F7FE5C3E65D8AF8B48AD6246925553")), + cm.exception) def testAddKeyFromServer(self): """Install a GnuPG key from a remote server.""" @@ -236,7 +225,7 @@ class TestAuthKeys(TestCase): with self._discard_stderr(): apt.auth.add_key_from_keyserver( - "0xa1bD8E9D78F7FE5C3E65D8AF8B48AD6246925553", + "0xa1bD8E9D78F7FE5C3E65D8AF8B48AD6246925553", "hkp://localhost:%d" % self.keyserver_port) ret = apt.auth.list_keys() |