<commit_before>from django.contrib.auth.models import User
from django.test import TestCase
from django.test.simple import DjangoTestSuiteRunner
from django.utils.timezone import now
from django.db.models import Q

from zephyr.models import Message, UserProfile, Stream, Recipient, Subscription, \
    filter_by_subscriptions, get_display_recipient, Realm, Client
from zephyr.tornadoviews import json_get_updates, api_get_messages
from zephyr.views import gather_subscriptions
from zephyr.decorator import RespondAsynchronously, RequestVariableConversionError
from zephyr.lib.initial_password import initial_password, initial_api_key
from zephyr.lib.actions import do_send_message
from zephyr.lib.bugdown import convert

import simplejson
import subprocess
import optparse
from django.conf import settings
import re
import sys

try:
    settings.TEST_SUITE
except:
    print
    print "ERROR: Test suite only runs correctly with --settings=humbug.test_settings"
    print
    sys.exit(1)

def find_key_by_email(address):
    from django.core.mail import outbox
    key_regex = re.compile("accounts/do_confirm/([a-f0-9]{40})>")
    for message in reversed(outbox):
        if address in message.to:
            return key_regex.search(message.body).groups()[0]

def message_ids(result):
    return set(message['id'] for message in result['messages'])

class AuthedTestCase(TestCase):
    def login(self, email, password=None):<commit_msg>Remove last tests.py dependency on views.py<commit_after>from django.contrib.auth.models import User
from django.test import TestCase
from django.test.simple import DjangoTestSuiteRunner
from django.utils.timezone import now
from django.db.models import Q

from zephyr.models import Message, UserProfile, Stream, Recipient, Subscription, \
    filter_by_subscriptions, get_display_recipient, Realm, Client
from zephyr.tornadoviews import json_get_updates, api_get_messages
from zephyr.decorator import RespondAsynchronously, RequestVariableConversionError
from zephyr.lib.initial_password import initial_password, initial_api_key
from zephyr.lib.actions import do_send_message, gather_subscriptions
from zephyr.lib.bugdown import convert

import simplejson
import subprocess
import optparse
from django.conf import settings
import re
import sys

try:
    settings.TEST_SUITE
except:
    print
    print "ERROR: Test suite only runs correctly with --settings=humbug.test_settings"
    print
    sys.exit(1)

def find_key_by_email(address):
    from django.core.mail import outbox
    key_regex = re.compile("accounts/do_confirm/([a-f0-9]{40})>")
    for message in reversed(outbox):
        if address in message.to:
            return key_regex.search(message.body).groups()[0]

def message_ids(result):
    return set(message['id'] for message in result['messages'])

class AuthedTestCase(TestCase):
    def login(self, email, password=<PASSWORD>):
{'fraction_non_alphanumeric': 0.07553707553707553, 'fraction_numerical': 0.004158004158004158, 'mean_word_length': 5.248917748917749, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '2590485', 'n_tokens_mistral': 852, 'n_tokens_neox': 843, 'n_words': 241}