# Path: subspace/utils.py
# def digest(s):
#     if not isinstance(s, str):
#         s = str(s)
#     return hashlib.sha1(s).digest()
# 
# def sharedPrefix(args):
#     """
#     Find the shared prefix between the strings.
# 
#     For instance:
# 
#         sharedPrefix(['blahblah', 'blahwhat'])
# 
#     returns 'blah'.
#     """
#     i = 0
#     while i < min(map(len, args)):
#         if len(set(map(operator.itemgetter(i), args))) != 1:
#             break
#         i += 1
#     return args[0][:i]
# 
# class OrderedSet(list):
#     """
#     Acts like a list in all ways, except in the behavior of the :meth:`push` method.
#     """
# 
#     def push(self, thing):
#         """
#         1. If the item exists in the list, it's removed
#         2. The item is pushed to the end of the list
#         """
#         if thing in self:
#             self.remove(thing)
#         self.append(thing)


import hashlib
from twisted.trial import unittest
from subspace.utils import digest, sharedPrefix, OrderedSet




class UtilsTest(unittest.TestCase):
    def test_digest(self):
        d = hashlib.sha1('1').digest()

# Path: subspace/utils.py
# def digest(s):
#     if not isinstance(s, str):
#         s = str(s)
#     return hashlib.sha1(s).digest()
# 
# def sharedPrefix(args):
#     """
#     Find the shared prefix between the strings.
# 
#     For instance:
# 
#         sharedPrefix(['blahblah', 'blahwhat'])
# 
#     returns 'blah'.
#     """
#     i = 0
#     while i < min(map(len, args)):
#         if len(set(map(operator.itemgetter(i), args))) != 1:
#             break
#         i += 1
#     return args[0][:i]
# 
# class OrderedSet(list):
#     """
#     Acts like a list in all ways, except in the behavior of the :meth:`push` method.
#     """
# 
#     def push(self, thing):
#         """
#         1. If the item exists in the list, it's removed
#         2. The item is pushed to the end of the list
#         """
#         if thing in self:
#             self.remove(thing)
#         self.append(thing)


# Path: subspace/tests/test_utils.py
import hashlib
from twisted.trial import unittest
from subspace.utils import digest, sharedPrefix, OrderedSet





class UtilsTest(unittest.TestCase):
    def test_digest(self):
        d = hashlib.sha1('1').digest()

        self.assertEqual(d, digest(1))