Mercurial > hg-stable
changeset 29233:318534bb5dfd
tests: make 'f' utility import hashlib unconditionally
It must exist on Python 2.5+.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 May 2016 10:45:32 +0900 |
parents | 3dad34e9d134 |
children | 393aef802535 |
files | tests/f |
diffstat | 1 files changed, 5 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/f Sun May 15 10:41:01 2016 +0900 +++ b/tests/f Sun May 15 10:45:32 2016 +0900 @@ -26,6 +26,7 @@ from __future__ import absolute_import import glob +import hashlib import optparse import os import re @@ -80,17 +81,11 @@ else: facts.append('older than %s' % opts.newer) if opts.md5 and content is not None: - try: - from hashlib import md5 - except ImportError: - from md5 import md5 - facts.append('md5=%s' % md5(content).hexdigest()[:opts.bytes]) + h = hashlib.md5(content) + facts.append('md5=%s' % h.hexdigest()[:opts.bytes]) if opts.sha1 and content is not None: - try: - from hashlib import sha1 - except ImportError: - from sha import sha as sha1 - facts.append('sha1=%s' % sha1(content).hexdigest()[:opts.bytes]) + h = hashlib.sha1(content) + facts.append('sha1=%s' % h.hexdigest()[:opts.bytes]) if isstdin: outfile.write(', '.join(facts) + '\n') elif facts: