# Path: ejtp/util/hasher.py
# HASH_FUNCTION = 'sha1' # was md5
# def make(string):
# def make6(string):
# def maken(string, n):
# def strict(obj=None):
# def strictify(jsonstring):
# def checksum(obj):
# 
# Path: ejtp/util/crashnicely.py
# class Guard(object):
# 	'''
# 	Class of exception catching and printing objects.
# 
# 	>>> with Guard():
# 	...     print("This code is okay")
# 	This code is okay
# 	>>> with Guard(print_traceback=False):
# 	... 	print("This code is bad"[""]) # doctest: +ELLIPSIS
# 	Traceback <traceback object at ...> caught by <ejtp.util.crashnicely.Guard object at ...>
# 	'''
# 	def __init__(self, print_catch=True, print_traceback=True):
# 		# Workaround for doctest being dumb, will fix better later
# 		self.print_catch = print_catch 
# 		self.print_traceback = print_traceback
# 
# 	def __enter__(self):
# 		pass
# 
# 	def __exit__(self, exc_type, exc_value, exc_traceback):
# 		if not exc_traceback:
# 			return True
# 		if self.print_catch:
# 			print("Traceback %s caught by %s" % (exc_traceback, self))
# 		if self.print_traceback:
# 			traceback.print_exception(exc_type, exc_value, exc_traceback)
# 		return True
# 
# Path: ejtp/util/compat.py



import sys
import json
from persei import RawData, String
from ejtp.util import hasher
from ejtp.util.crashnicely import Guard
from ejtp.util.compat import unittest, StringIO

    def test_string(self):
        expected = '5006d6f8302000e8b87fef5c50c071d6d97b4e88'
        value = hasher.checksum('test')
        self.assertEqual(RawData(expected), RawData(value))


class TestCrashNicely(unittest.TestCase):

    def setUp(self):
        # Use same output stream for both
        sys.stderr = sys.stdout = self.output = StringIO()

    def _assertInOutput(self, expected):
        self.assertIn(expected, self.output.getvalue())

    def _assertNotInOutput(self, expected):
        self.assertNotIn(expected, self.output.getvalue())

    def test_ok(self):
        with Guard():
            print('ok')
        self._assertInOutput('ok')

    def test_with_print_traceback(self):
        with Guard():
            raise AssertionError()
        self._assertInOutput('AssertionError')

    def test_without_print_traceback(self):

# Path: ejtp/util/hasher.py
# HASH_FUNCTION = 'sha1' # was md5
# def make(string):
# def make6(string):
# def maken(string, n):
# def strict(obj=None):
# def strictify(jsonstring):
# def checksum(obj):
# 
# Path: ejtp/util/crashnicely.py
# class Guard(object):
# 	'''
# 	Class of exception catching and printing objects.
# 
# 	>>> with Guard():
# 	...     print("This code is okay")
# 	This code is okay
# 	>>> with Guard(print_traceback=False):
# 	... 	print("This code is bad"[""]) # doctest: +ELLIPSIS
# 	Traceback <traceback object at ...> caught by <ejtp.util.crashnicely.Guard object at ...>
# 	'''
# 	def __init__(self, print_catch=True, print_traceback=True):
# 		# Workaround for doctest being dumb, will fix better later
# 		self.print_catch = print_catch 
# 		self.print_traceback = print_traceback
# 
# 	def __enter__(self):
# 		pass
# 
# 	def __exit__(self, exc_type, exc_value, exc_traceback):
# 		if not exc_traceback:
# 			return True
# 		if self.print_catch:
# 			print("Traceback %s caught by %s" % (exc_traceback, self))
# 		if self.print_traceback:
# 			traceback.print_exception(exc_type, exc_value, exc_traceback)
# 		return True
# 
# Path: ejtp/util/compat.py



# Path: ejtp/tests/test_util.py
import sys
import json
from persei import RawData, String
from ejtp.util import hasher
from ejtp.util.crashnicely import Guard
from ejtp.util.compat import unittest, StringIO


    def test_string(self):
        expected = '5006d6f8302000e8b87fef5c50c071d6d97b4e88'
        value = hasher.checksum('test')
        self.assertEqual(RawData(expected), RawData(value))


class TestCrashNicely(unittest.TestCase):

    def setUp(self):
        # Use same output stream for both
        sys.stderr = sys.stdout = self.output = StringIO()

    def _assertInOutput(self, expected):
        self.assertIn(expected, self.output.getvalue())

    def _assertNotInOutput(self, expected):
        self.assertNotIn(expected, self.output.getvalue())

    def test_ok(self):
        with Guard():
            print('ok')
        self._assertInOutput('ok')

    def test_with_print_traceback(self):
        with Guard():
            raise AssertionError()
        self._assertInOutput('AssertionError')

    def test_without_print_traceback(self):

        with Guard(print_traceback=False):