<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json

import pytest
import requests


@pytest.fixture(scope='session')
def session_capabilities(session_capabilities):
    session_capabilities.setdefault('tags', []).append('oneanddone')
    return session_capabilities


@pytest.fixture
def persona_test_user():
    max_retries = 5
    attempt = 1
    while attempt <= max_retries:
        msg = 'There was a problem getting a personatestuser -- attempt {num}: '.format(
            num=attempt)
        try:
            response = requests.get('http://personatestuser.org/email')
            user_info = response.json()
            if user_info.get('email'):
                return user_info
        except ValueError:
            msg += 'No json was returned from personatestuser.org. \n'
            msg += 'Response status / content: {status} / {content}'.format(
                status=response.status_code,
                content=response.content)
        else:
            msg += json.dumps(user_info, indent=4, sort_keys=True)
        print msg
        attempt += 1
    raise Exception(msg)


@pytest.fixture(scope='function')
def new_user(persona_test_user):
    return {
        'email': persona_test_user['email'],
        'password': <PASSWORD>['<PASSWORD>'],
        'name': persona_test_user['email'].split('@')[0],
        'username': persona_test_user['email'].split('@')[0],
        'url': 'http://www.mozilla.org/'
    }


@pytest.fixture(scope='session')
def base_url(base_url, request):
    return base_url or request.getfuncargvalue("live_server").url


@pytest.fixture(scope='function')
def is_local(base_url):
    return '127.0.0.1' in base_url or 'localhost' in base_url


@pytest.fixture(scope='function', autouse=True)
def use_transactional_db(base_url, is_local, request):
    if is_local:
        # if we are running locally we need the transactional_db fixture
        request.getfuncargvalue("transactional_db")


@pytest.fixture(scope='function')
def task(base_url, is_local):
    if is_local:
        from oneanddone.tasks.tests import TaskFactory
        return TaskFactory.create()


@pytest.fixture(scope='function')
def nonrepeatable_assigned_task(base_url, is_local, new_user):
    if is_local:
        from oneanddone.tasks.tests import TaskFactory
        return TaskFactory.create(
            repeatable=False,
            taskattempt_set={"user": new_user.email, "state": 1})
<commit_msg>Wrong parameter<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json

import pytest
import requests


@pytest.fixture(scope='session')
def session_capabilities(session_capabilities):
    session_capabilities.setdefault('tags', []).append('oneanddone')
    return session_capabilities


@pytest.fixture
def persona_test_user():
    max_retries = 5
    attempt = 1
    while attempt <= max_retries:
        msg = 'There was a problem getting a personatestuser -- attempt {num}: '.format(
            num=attempt)
        try:
            response = requests.get('http://personatestuser.org/email')
            user_info = response.json()
            if user_info.get('email'):
                return user_info
        except ValueError:
            msg += 'No json was returned from personatestuser.org. \n'
            msg += 'Response status / content: {status} / {content}'.format(
                status=response.status_code,
                content=response.content)
        else:
            msg += json.dumps(user_info, indent=4, sort_keys=True)
        print msg
        attempt += 1
    raise Exception(msg)


@pytest.fixture(scope='function')
def new_user(persona_test_user):
    return {
        'email': persona_test_user['email'],
        'password': <PASSWORD>'],
        'name': persona_test_user['email'].split('@')[0],
        'username': persona_test_user['email'].split('@')[0],
        'url': 'http://www.mozilla.org/'
    }


@pytest.fixture(scope='session')
def base_url(base_url, request):
    return base_url or request.getfuncargvalue("live_server").url


@pytest.fixture(scope='function')
def is_local(base_url):
    return '127.0.0.1' in base_url or 'localhost' in base_url


@pytest.fixture(scope='function', autouse=True)
def use_transactional_db(base_url, is_local, request):
    if is_local:
        # if we are running locally we need the transactional_db fixture
        request.getfuncargvalue("transactional_db")


@pytest.fixture(scope='function')
def task(base_url, is_local):
    if is_local:
        from oneanddone.tasks.tests import TaskFactory
        return TaskFactory.create()


@pytest.fixture(scope='function')
def nonrepeatable_assigned_task(base_url, is_local, new_user):
    if is_local:
        from oneanddone.tasks.tests import TaskFactory
        return TaskFactory.create(
            repeatable=False,
            taskattempt_set={"user": new_user['email'], "state": 1})
{'fraction_non_alphanumeric': 0.1175, 'fraction_numerical': 0.006538461538461538, 'mean_word_length': 3.1277777777777778, 'pattern_counts': {'":': 4, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '1444453', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1574, 'n_words': 381}