<commit_before>"""Enables unit testing from root directory of source."""
import sys
import os.path
import inspect


_test_dir = os.path.dirname(inspect.getfile(inspect.currentframe()))
sys.path.insert(0, os.path.join(_test_dir, '..', 'src'))

from rez.tests.test_build import TestBuild
from rez.tests.test_commands import TestCommands
from rez.tests.test_context import TestContext
from rez.tests.test_formatter import TestFormatter
from rez.tests.test_rex import TestRex
from rez.tests.test_shells import TestShells
from rez.tests.test_solver import TestSolver
from rez.tests.test_resources import TestResources
from rez.tests.test_packages import TestPackages
from rez.tests.test_config import TestConfig
from rez.tests.test_release import TestRelease
from rez.tests.test_completion import TestCompletion
from rez.tests.test_version import TestVersions<commit_msg>test.py: use unittest2 discovery / load_tests protocol<commit_after>"""Enables unit testing from root directory of source."""
import os.path
import inspect


def load_tests(loader, standard_tests, pattern):
    root_test_dir = os.path.dirname(inspect.getfile(inspect.currentframe()))
    src_dir = os.path.join(root_test_dir, '..', 'src')
    src_test_dir = os.path.join(src_dir, 'rez', 'tests')

    if not pattern:
        pattern = 'test_*.py'
    suite = loader.discover(src_test_dir, pattern=pattern,
                            top_level_dir=src_dir)
    if standard_tests:
        suite.addTests(standard_tests)
    return suite
{'fraction_non_alphanumeric': 0.09127248500999334, 'fraction_numerical': 0.0013324450366422385, 'mean_word_length': 4.8671875, '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': '4841729', 'n_tokens_mistral': 463, 'n_tokens_neox': 457, 'n_words': 114}