<commit_before>from contextlib import contextmanager

import fudge

from django.test import TestCase, Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User

from users.models import Profile, Link


@contextmanager
def given_user(fake_auth, user):
    """Context manager to respond to any login call with a specific user."""
    fake_auth.expects_call().returns(user)
    yield


class ProfileAdmin(TestCase):
    
    def setUp(self):
        self.client = Client()
        self.User = User.objects.create(
            username=u'test_ross',
            password=u'<PASSWORD>',
            is_active=True
        )
        self.profile = Profile.objects.create(
            user=self.User
        )
<commit_msg>Suppress locale URL middleware for profile test.<commit_after>from contextlib import contextmanager

import fudge

from django.test import TestCase, Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User

from commons.middleware import LocaleURLMiddleware
from users.models import Profile, Link


@contextmanager
def given_user(fake_auth, user):
    """Context manager to respond to any login call with a specific user."""
    fake_auth.expects_call().returns(user)
    yield


# Apply this decorator to a test to turn off the middleware that goes around
# inserting 'en_US' redirects into all the URLs
suppress_locale_middleware = fudge.with_patched_object(LocaleURLMiddleware,
                                                       'process_request',
                                                       lambda *args: None)


class ProfileAdmin(TestCase):
    
    def setUp(self):
        self.client = Client()
        self.User = User.objects.create(
            username=u'test_ross',
            password=u'<PASSWORD>',
            is_active=True
        )
        self.profile = Profile.objects.create(
            user=self.User
        )

    @suppress_locale_middleware
{'fraction_non_alphanumeric': 0.07439271255060728, 'fraction_numerical': 0.0, 'mean_word_length': 2.588021778584392, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704210', 'n_tokens_mistral': 516, 'n_tokens_neox': 512, 'n_words': 150}