Merge branch '8508-datamanager-test-badpaths' of https://github.com/wtsi-hgi/arvados...
[arvados.git] / sdk / python / tests / arvados_testutil.py
index ea318c6de05c9624d8517d15e8c4071f287a4ab9..b2cf43652bce288858dca4a1db1a121b040af9ec 100644 (file)
@@ -47,6 +47,8 @@ def mock_api_responses(api_client, body, codes, headers={}):
     return mock.patch.object(api_client._http, 'request', side_effect=queue_with((
         (fake_httplib2_response(code, **headers), body) for code in codes)))
 
+def str_keep_locator(s):
+    return '{}+{}'.format(hashlib.md5(s).hexdigest(), len(s))
 
 class FakeCurl:
     @classmethod
@@ -126,8 +128,7 @@ class MockStreamReader(object):
     def __init__(self, name='.', *data):
         self._name = name
         self._data = ''.join(data)
-        self._data_locators = ['{}+{}'.format(hashlib.md5(d).hexdigest(),
-                                              len(d)) for d in data]
+        self._data_locators = [str_keep_locator(d) for d in data]
         self.num_retries = 0
 
     def name(self):