<commit_before>from agentserver.admin import Admin, color_text, HEADER_COLOR
from agentserver.db.models import models, User, UserAuthToken, Agent, AgentAuthToken

import mock
import unittest
import re
import sys
import os
from cStringIO import StringIO
from contextlib import contextmanager
from datetime import datetime
from tempfile import NamedTemporaryFile
from resources.test_admin.admin_output import *


resources = os.path.join(os.path.abspath(
    os.path.dirname(__file__)), 'resources')


# http://schinckel.net/2013/04/15/capture-and-test-sys.stdout-sys.stderr-in-unittest.testcase/
@contextmanager
def capture(command, *args, **kwargs):
    out, sys.stdout = sys.stdout, StringIO()
    try:
        command(*args, **kwargs)
        sys.stdout.seek(0)
        yield sys.stdout.read().strip()
    finally:
        sys.stdout = out


def highlight_header_row(text):
    lines = text.split('\n')
    components = re.split(r'(\s+)', lines.pop(0))
    highlighted = []
    for c in components:
        if not re.match(r'^\s+$', c):
            highlighted.append(color_text(c, color=HEADER_COLOR))<commit_msg>Remove unnecessary function from test_admin.py<commit_after>from agentserver.admin import Admin, color_text, HEADER_COLOR
from agentserver.db.models import models, User, UserAuthToken, Agent, AgentAuthToken

import mock
import unittest
import re
import sys
import os
from cStringIO import StringIO
from contextlib import contextmanager
from datetime import datetime
from tempfile import NamedTemporaryFile
from resources.test_admin.admin_output import *


# http://schinckel.net/2013/04/15/capture-and-test-sys.stdout-sys.stderr-in-unittest.testcase/
@contextmanager
def capture(command, *args, **kwargs):
    out, sys.stdout = sys.stdout, StringIO()
    try:
        command(*args, **kwargs)
        sys.stdout.seek(0)
        yield sys.stdout.read().strip()
    finally:
        sys.stdout = out


def highlight_header_row(text):
    lines = text.split('\n')
    components = re.split(r'(\s+)', lines.pop(0))
    highlighted = []
    for c in components:
        if not re.match(r'^\s+$', c):
            highlighted.append(color_text(c, color=HEADER_COLOR))
{'fraction_non_alphanumeric': 0.11534926470588236, 'fraction_numerical': 0.009191176470588236, 'mean_word_length': 3.9142212189616252, 'pattern_counts': {'":': 0, '<': 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': '5243178', 'n_tokens_mistral': 676, 'n_tokens_neox': 664, 'n_words': 167}