def test_automatic_default_to_sha1(self): """Test automatic default to sha1 if md5 is missing from hashlib entirely""" for version, expected in { self.sys_v3_8: (True, 'sha1'), self.sys_v3_9: (False, 'sha1'), self.sys_v4_8: (False, 'sha1'), }.items(): _set_allowed_viable_default_hashes(self.sha1Default, version) set_hash_format(None, self.sha1Default, version) assert _get_hash_object(None, self.sha1Default, version) == expected
def test_automatic_default_to_md5(self): """Test automatic default to md5 even if sha1 available""" for version, expected in { self.sys_v3_8: (True, 'md5'), self.sys_v3_9: (False, 'md5'), self.sys_v4_8: (False, 'md5'), }.items(): _set_allowed_viable_default_hashes(self.md5Default, version) set_hash_format(None, self.md5Default, version) assert _get_hash_object(None, self.md5Default, version) == expected
def test_automatic_default_to_sha256(self): """Test automatic default to sha256 if other algorithms available but throw""" for version, expected in { self.sys_v3_8: (True, 'sha256'), self.sys_v3_9: (False, 'sha256'), self.sys_v4_8: (False, 'sha256'), }.items(): _set_allowed_viable_default_hashes(self.sha256Default, version) set_hash_format(None, self.sha256Default, version) assert _get_hash_object(None, self.sha256Default, version) == expected
def tearDown(self): """Return SCons back to the normal global state for the hashing functions.""" _set_allowed_viable_default_hashes(hashlib, sys) set_hash_format(None)