def test_calculate_filename(self, hashlib): sha = Mock() sha.hexdigest.return_value = 'indigestible' hashlib.sha1.return_value = sha truck = ImageTruck('razors', None, None) eq_(truck.calculate_filename(), 'indigestible') hashlib.sha1.assert_called_with('razors')