summaryrefslogtreecommitdiff
path: root/tests/test_hashes.py
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2011-04-06 11:15:47 +0200
committerJulian Andres Klode <jak@debian.org>2011-04-06 11:15:47 +0200
commit5ad927a38cad08a2d79f327e7bb3cc46316fa6a4 (patch)
tree0ad729e5abaeaa66923883251587695ea2e4c00c /tests/test_hashes.py
parentb766dc001aeea1c18b0c17c1d5029673ef539ef0 (diff)
downloadpython-apt-5ad927a38cad08a2d79f327e7bb3cc46316fa6a4.tar.gz
all: Fix all instances of ResourceWarning about unclosed files
Diffstat (limited to 'tests/test_hashes.py')
-rw-r--r--tests/test_hashes.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/test_hashes.py b/tests/test_hashes.py
index e0aabe09..660373cb 100644
--- a/tests/test_hashes.py
+++ b/tests/test_hashes.py
@@ -82,11 +82,16 @@ class TestHashString(unittest.TestCase):
def setUp(self):
"""Prepare the test by reading the file."""
- self.hashes = apt_pkg.Hashes(open(apt_pkg.__file__))
+ self.file = open(apt_pkg.__file__)
+ self.hashes = apt_pkg.Hashes(self.file)
self.md5 = apt_pkg.HashString("MD5Sum", self.hashes.md5)
self.sha1 = apt_pkg.HashString("SHA1", self.hashes.sha1)
self.sha256 = apt_pkg.HashString("SHA256", self.hashes.sha256)
+ def tearDown(self):
+ """Cleanup, Close the file object used for the tests."""
+ self.file.close()
+
def test_md5(self):
"""hashes: Test apt_pkg.HashString().md5"""
self.assertEqual("MD5Sum:%s" % self.hashes.md5, str(self.md5))