<commit_before>from __future__ import unicode_literals, print_function

from pprint import pformat
from collections import OrderedDict

from ashes import AshesEnv, Template
from tests import dust_site_tests
from tests.core import OPS

DEFAULT_WIDTH = 70

LEGEND = '. = passed, _ = skipped, X = failed, E = exception'

import sys
PY3 = (sys.version_info[0] == 3)
if PY3:
    unicode = str
    basestring = str


def get_line(title, items, twidth=20, talign='>', width=DEFAULT_WIDTH):
    if len(title) > twidth:
        title = title[:twidth - 3] + '...'
    rwidth = width - twidth
    items = list(items or [])
    pw = rwidth / len(items)
    tmpl = '{title:{talign}{twidth}}' + ('{:^{pw}}' * len(items))
    #print(title, talign, twidth, pw, items)
    return tmpl.format(title=title,
                       talign=talign,
                       twidth=twidth,
                       pw=pw,
                       *items)


def get_test_results(raise_on=None):
    env = AshesEnv()
    ret = []
    for tc in dust_site_tests:
        env.register(Template(tc.name, tc.template, env=env, lazy=True))
    for tc in dust_site_tests:
        raise_exc = (tc.name == raise_on)
        ret.append(tc.get_test_result(env, raise_exc=raise_exc))
    return ret
<commit_msg>now even tests run smoothly under python 3<commit_after>from __future__ import unicode_literals, print_function

from pprint import pformat
from collections import OrderedDict

from ashes import AshesEnv, Template
from tests import dust_site_tests
from tests.core import OPS

DEFAULT_WIDTH = 70

LEGEND = '. = passed, _ = skipped, X = failed, E = exception'

import sys
PY3 = (sys.version_info[0] == 3)
if PY3:
    unicode = str
    basestring = str


def get_line(title, items, twidth=20, talign='>', width=DEFAULT_WIDTH):
    if len(title) > twidth:
        title = title[:twidth - 3] + '...'
    rwidth = width - twidth
    items = list(items or [])
    pw = int(rwidth / len(items))
    tmpl = '{title:{talign}{twidth}}' + ('{:^{pw}}' * len(items))
    return tmpl.format(title=title,
                       talign=talign,
                       twidth=twidth,
                       pw=pw,
                       *items)


def get_test_results(raise_on=None):
    env = AshesEnv()
    ret = []
    for tc in dust_site_tests:
        env.register(Template(tc.name, tc.template, env=env, lazy=True))
    for tc in dust_site_tests:
        raise_exc = (tc.name == raise_on)
        ret.append(tc.get_test_result(env, raise_exc=raise_exc))
    return ret

{'fraction_non_alphanumeric': 0.11613158937772493, 'fraction_numerical': 0.0075307173999207295, 'mean_word_length': 2.6954612005856515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4762018', 'n_tokens_mistral': 855, 'n_tokens_neox': 823, 'n_words': 214}