Commit 915f05b7 authored by Jason R. Coombs's avatar Jason R. Coombs

Use 'is_valid' instead of simply 'valid' or 'check', which are less clear...

Use 'is_valid' instead of simply 'valid' or 'check', which are less clear about the purpose of the method. Fixes AttributeError introduces in 0.9.2. Fixes #42.
parent b34eec59
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
CHANGES CHANGES
======= =======
-----
0.9.3
-----
* Issue #42: Fix new ``AttributeError`` introduced in last fix.
----- -----
0.9.2 0.9.2
----- -----
......
...@@ -202,7 +202,7 @@ class ContentChecker(object): ...@@ -202,7 +202,7 @@ class ContentChecker(object):
""" """
return return
def check(self): def is_valid(self):
""" """
Check the hash. Return False if validation fails. Check the hash. Return False if validation fails.
""" """
...@@ -239,7 +239,7 @@ class HashChecker(ContentChecker): ...@@ -239,7 +239,7 @@ class HashChecker(ContentChecker):
def feed(self, block): def feed(self, block):
self.hash.update(block) self.hash.update(block)
def check(self): def is_valid(self):
return self.hash.hexdigest() == self.expected return self.hash.hexdigest() == self.expected
def report(self, reporter, template): def report(self, reporter, template):
...@@ -445,7 +445,7 @@ class PackageIndex(Environment): ...@@ -445,7 +445,7 @@ class PackageIndex(Environment):
""" """
checker.report(self.debug, checker.report(self.debug,
"Validating %%s checksum for %s" % filename) "Validating %%s checksum for %s" % filename)
if not checker.valid(): if not checker.is_valid():
tfp.close() tfp.close()
os.unlink(filename) os.unlink(filename)
raise DistutilsError( raise DistutilsError(
......
...@@ -151,18 +151,18 @@ class TestContentCheckers(unittest.TestCase): ...@@ -151,18 +151,18 @@ class TestContentCheckers(unittest.TestCase):
checker.feed('You should probably not be using MD5'.encode('ascii')) checker.feed('You should probably not be using MD5'.encode('ascii'))
self.assertEqual(checker.hash.hexdigest(), self.assertEqual(checker.hash.hexdigest(),
'f12895fdffbd45007040d2e44df98478') 'f12895fdffbd45007040d2e44df98478')
self.assertTrue(checker.check()) self.assertTrue(checker.is_valid())
def test_other_fragment(self): def test_other_fragment(self):
"Content checks should succeed silently if no hash is present" "Content checks should succeed silently if no hash is present"
checker = setuptools.package_index.HashChecker.from_url( checker = setuptools.package_index.HashChecker.from_url(
'http://foo/bar#something%20completely%20different') 'http://foo/bar#something%20completely%20different')
checker.feed('anything'.encode('ascii')) checker.feed('anything'.encode('ascii'))
self.assertTrue(checker.check()) self.assertTrue(checker.is_valid())
def test_blank_md5(self): def test_blank_md5(self):
"Content checks should succeed if a hash is empty" "Content checks should succeed if a hash is empty"
checker = setuptools.package_index.HashChecker.from_url( checker = setuptools.package_index.HashChecker.from_url(
'http://foo/bar#md5=') 'http://foo/bar#md5=')
checker.feed('anything'.encode('ascii')) checker.feed('anything'.encode('ascii'))
self.assertTrue(checker.check()) self.assertTrue(checker.is_valid())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment