<commit_before>"""Package tests."""
#
# (C) Pywikibot team, 2007-2021
#
# Distributed under the terms of the MIT license.
#
__all__ = (
    'requests', 'unittest', 'TestRequest', 'patch_request', 'unpatch_request',
    'mock', 'Mock', 'MagicMock', 'patch')

import functools
import os
import unittest
import warnings

from contextlib import suppress
from itertools import chain
from unittest import mock
from unittest.mock import MagicMock, Mock, patch

# Verify that the unit tests have a base working environment:
# - requests is mandatory
#   however if unavailable this will fail on use; see pywikibot/tools.py
# - mwparserfromhell is optional, so is only imported in textlib_tests
import requests

import pywikibot.data.api

from pywikibot import config
from pywikibot.data.api import CachedRequest
from pywikibot.data.api import Request as _original_Request
from pywikibot.tools import PYTHON_VERSION

_root_dir = os.path.split(os.path.split(__file__)[0])[0]


def join_root_path(*names):
    """Return a path relative to the root directory."""
    return os.path.join(_root_dir, *names)


def create_path_func(base_func, subpath):
    """Return a function returning a path relative to the given directory."""
    func = functools.partial(base_func, subpath)
    func.path = base_func.path + '/' + subpath
    func.__doc__ = 'Return a path relative to `{0}/`.'.format(func.path)
    return func

<commit_msg>[tests] Don't import standard library parts from tests<commit_after>"""Package tests."""
#
# (C) Pywikibot team, 2007-2021
#
# Distributed under the terms of the MIT license.
#
__all__ = (
    'create_path_func', 'join_cache_path', 'join_data_path',
    'join_html_data_path', 'join_images_path', 'join_pages_path',
    'join_root_path', 'join_xml_data_path', 'patch_request', 'unittest_print',
    'unpatch_request',
)

import functools
import os
import unittest
import warnings

from contextlib import suppress
from itertools import chain
from unittest import mock  # noqa: F401
from unittest.mock import MagicMock, Mock, patch  # noqa: F401

# Verify that the unit tests have a base working environment:
# - requests is mandatory
#   however if unavailable this will fail on use; see pywikibot/tools.py
# - mwparserfromhell is optional, so is only imported in textlib_tests
import requests  # noqa: F401

import pywikibot.data.api

from pywikibot import config
from pywikibot.data.api import CachedRequest
from pywikibot.data.api import Request as _original_Request
from pywikibot.tools import PYTHON_VERSION

_root_dir = os.path.split(os.path.split(__file__)[0])[0]


def join_root_path(*names):
    """Return a path relative to the root directory."""
    return os.path.join(_root_dir, *names)


def create_path_func(base_func, subpath):
    """Return a function returning a path relative to the given directory."""
    func = functools.partial(base_func, subpath)
    func.path = base_func.path + '/' + subpath
    func.__doc__ = 'Return a path relative to `{0}/`.'.format(func.path)
    return func


{'fraction_non_alphanumeric': 0.09665673618007282, 'fraction_numerical': 0.010261502813637868, 'mean_word_length': 4.712665406427221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '3259720', 'n_tokens_mistral': 968, 'n_tokens_neox': 942, 'n_words': 311}