def all_tests_suite(project_dir=None): def get_suite(): suite_names = [ "simplejson.tests.%s" % (os.path.splitext(f)[0],) for f in os.listdir(os.path.dirname(__file__)) if f.startswith("test_") and f.endswith(".py") ] return additional_tests( suite=unittest.TestLoader().loadTestsFromNames(suite_names), project_dir=project_dir, ) suite = get_suite() import simplejson if simplejson._import_c_make_encoder() is None: suite.addTest(TestMissingSpeedups()) else: suite = unittest.TestSuite( [ suite, NoExtensionTestSuite([get_suite()]), ] ) return suite
def run(self, result): import simplejson run = unittest.TestSuite.run run(self, result) if simplejson._import_c_make_encoder() is None: TestMissingSpeedups().run(result) else: simplejson._toggle_speedups(False) run(self, result) simplejson._toggle_speedups(True) return result
def all_tests_suite(): def get_suite(): return additional_tests( unittest.TestLoader().loadTestsFromNames([ 'simplejson.tests.test_bitsize_int_as_string', 'simplejson.tests.test_bigint_as_string', 'simplejson.tests.test_check_circular', 'simplejson.tests.test_decode', 'simplejson.tests.test_default', 'simplejson.tests.test_dump', 'simplejson.tests.test_encode_basestring_ascii', 'simplejson.tests.test_encode_for_html', 'simplejson.tests.test_errors', 'simplejson.tests.test_fail', 'simplejson.tests.test_float', 'simplejson.tests.test_indent', 'simplejson.tests.test_iterable', 'simplejson.tests.test_pass1', 'simplejson.tests.test_pass2', 'simplejson.tests.test_pass3', 'simplejson.tests.test_recursion', 'simplejson.tests.test_scanstring', 'simplejson.tests.test_separators', 'simplejson.tests.test_speedups', 'simplejson.tests.test_str_subclass', 'simplejson.tests.test_unicode', 'simplejson.tests.test_decimal', 'simplejson.tests.test_tuple', 'simplejson.tests.test_namedtuple', 'simplejson.tests.test_tool', 'simplejson.tests.test_for_json', 'simplejson.tests.test_subclass', 'simplejson.tests.test_raw_json', ])) suite = get_suite() import simplejson if simplejson._import_c_make_encoder() is None: suite.addTest(TestMissingSpeedups()) else: suite = unittest.TestSuite([ suite, NoExtensionTestSuite([get_suite()]), ]) return suite
def all_tests_suite(): def get_suite(): suite_names = [ 'simplejson.tests.%s' % (os.path.splitext(f)[0],) for f in os.listdir(os.path.dirname(__file__)) if f.startswith('test_') and f.endswith('.py') ] return additional_tests( unittest.TestLoader().loadTestsFromNames(suite_names)) suite = get_suite() import simplejson if simplejson._import_c_make_encoder() is None: suite.addTest(TestMissingSpeedups()) else: suite = unittest.TestSuite([ suite, NoExtensionTestSuite([get_suite()]), ]) return suite
import sys import os import time import socket import logging import traceback from collections import deque try: # Use simplejson instead of json because it is released more frequently and # is generally faster. import simplejson as json # However, if speedups are not installed, simplejson will be slow, so use # the built-in json instead. if json._import_c_make_encoder() is None: import json except ImportError: import json storm_log = logging.getLogger('storm') TUPLE_PROFILING = False json_encode = lambda x: json.dumps(x) json_decode = lambda x: json.loads(x) BLANK_LINE_CHECK = True # Save old stdout so we can still write to it after redirecting. old_stdout = sys.stdout