<commit_before># -*- coding: utf-8 -*-

import pickle
import zlib
import os

from .testresult import TestResult
from .continulet import continulet
from .suspendforwarder import SuspendForwarder


def _run_test(con, test_suite):
    sf = SuspendForwarder(con)
    result = TestResult()
    result.suspend_forwarder = sf
    test_suite(result)
    return ("finish", None)


class TestRunner(object):
    def __init__(self):
        self._continulet = None
        self._callback = {}

    def run(self, test_suite, suspender, filename="teststate.bin"):
        if os.path.exists(filename):
            self.load_file(filename)
            suspender.after_suspend()
        else:
            self._continulet = continulet(_run_test, test_suite)
        action, info = self.run_continulet()
        if action == "suspend":
            self.save_state(filename)<commit_msg>Change state file location.<commit_after># -*- coding: utf-8 -*-

import pickle
import zlib
import os
import os.path
import sys

from .testresult import TestResult
from .continulet import continulet
from .suspendforwarder import SuspendForwarder

BASE_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
DEFAULT_STATEFILE_PATH = os.path.join(BASE_DIR, "teststate.bin")

def _run_test(con, test_suite):
    sf = SuspendForwarder(con)
    result = TestResult()
    result.suspend_forwarder = sf
    test_suite(result)
    return ("finish", None)


class TestRunner(object):
    def __init__(self):
        self._continulet = None
        self._callback = {}

    def run(self, test_suite, suspender, filename=DEFAULT_STATEFILE_PATH):
        if not os.path.isabs(filename):
            filename = os.path.abspath(filename)
        if os.path.exists(filename):
            self.load_file(filename)
            suspender.after_suspend()
        else:
            self._continulet = continulet(_run_test, test_suite)
        action, info = self.run_continulet()
        if action == "suspend":
            self.save_state(filename)
{'fraction_non_alphanumeric': 0.10130391173520562, 'fraction_numerical': 0.0015045135406218655, 'mean_word_length': 3.0221774193548385, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '504686', 'n_tokens_mistral': 602, 'n_tokens_neox': 604, 'n_words': 138}