<commit_before>'''A small module for testing Serpent code.'''
import warnings; warnings.simplefilter('ignore')
from ethereum import tester as t
from ethereum.utils import coerce_to_int
from colorama import Fore, Style, init; init()
import sys

passed = Fore.GREEN + 'passed' + Style.RESET_ALL + ';'
failed = Style.BRIGHT + Fore.RED + 'failed' + Style.RESET_ALL + ';'


class Account(object):
    def __init__(self, rawaddr, privkey):
        self.hexaddr = rawaddr.encode('hex')
        self.privkey = self.private_key = privkey
        self.address = rawaddr
        self.address_as_int = coerce_to_int(rawaddr)

    def __str__(self):
        return "<account: 0x{}>".format(self.hexaddr)

    def __repr__(self):
        return "Account({}, {})".format(self.rawaddr, self.privkey)


class Tester(object):
    state = t.state()
    accounts = map(Account, zip(t.accounts, t.keys))
    def __init__(self, code, global_state=False):
        self.code = code
        if not global_state:
            self.state = t.state()
        self.contract = self.state.abi_contract(self.code)
        for name, obj in vars(self.contract).items():
            if getattr(obj, '__name__', '') == 'kall':
                obj.__name__ = str(name)
        
    def run_tests(self, test_cases):
        '''Runs a list of test cases.

        A test case is simple a 4-tuple with the following format:
            
            (name: str, args: tuple, kwds: dict, expected: object)<commit_msg>Fixed Account initialization error in Tester class.<commit_after>'''A small module for testing Serpent code.'''
import warnings; warnings.simplefilter('ignore')
from ethereum import tester as t
from ethereum.utils import coerce_to_int
from colorama import Fore, Style, init; init()
import sys

passed = Fore.GREEN + 'passed' + Style.RESET_ALL + ';'
failed = Style.BRIGHT + Fore.RED + 'failed' + Style.RESET_ALL + ';'


class Account(object):
    def __init__(self, rawaddr, privkey):
        self.hexaddr = rawaddr.encode('hex')
        self.privkey = self.private_key = privkey
        self.address = rawaddr
        self.address_as_int = coerce_to_int(rawaddr)

    def __str__(self):
        return "<account: 0x{}>".format(self.hexaddr)

    def __repr__(self):
        return "Account({}, {})".format(self.rawaddr, self.privkey)


class Tester(object):
    state = t.state()
    accounts = map(Account, t.accounts, t.keys)
    def __init__(self, code, global_state=False):
        self.code = code
        if not global_state:
            self.state = t.state()
        self.contract = self.state.abi_contract(self.code)
        for name, obj in vars(self.contract).items():
            if getattr(obj, '__name__', '') == 'kall':
                obj.__name__ = str(name)
        
    def run_tests(self, test_cases):
        '''Runs a list of test cases.

        A test case is simple a 4-tuple with the following format:
            
            (name: str, args: tuple, kwds: dict, expected: object)
{'fraction_non_alphanumeric': 0.1231130493123113, 'fraction_numerical': 0.0013418316001341832, 'mean_word_length': 2.813299232736573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2064021', 'n_tokens_mistral': 936, 'n_tokens_neox': 914, 'n_words': 253}