# Path: django_performance_testing/test_runner.py
# class DjptDjangoTestRunnerMixin(object):
# class DjptTestRunnerMixin(object):
#     class DjptTestRunner(DjptTestRunnerMixin, test_runner_cls.test_runner):
#     class DjptDjangoTestRunner(DjptDjangoTestRunnerMixin, test_runner_cls):
#     def run(self, *a, **kw):
# def wrap_cls_method(cls, method_name, collector_id, ctx_key, is_cls_method):
# def get_runner_with_djpt_mixin(*a, **kw):
#     def addTest(suite_self, test):
#     def fn_to_id(fn):
# def integrate_into_django_test_runner():
# 
# Path: django_performance_testing/serializer.py
# class Reader:
#     def __init__(self, fpath):
#         self.fpath = fpath
# 
#     def read_all(self):
#         with open(self.fpath, 'rb') as f:
#             data = f.read()
#         if not data:
#             return []
#         deserialized = pickle.loads(data)
#         for (sender, results, context) in deserialized:
#             results_read.send(sender=sender, results=results, context=context)
#         return deserialized


from datetime import timedelta
from django.contrib.auth.models import Group
from django.test.utils import get_runner
from django.utils import six
from django_performance_testing import test_runner as djpt_test_runner_module
from django_performance_testing.serializer import Reader
from freezegun import freeze_time
from testapp.test_helpers import (override_current_context,
                                  run_testcases_with_django_runner)
import pytest
import unittest
import re
class MyTestSuite(object):

    def addTest(self, test):
        pass


class MyTestRunner(object):
    pass


class MyDjangoTestRunner(object):
    test_runner = MyTestRunner
    test_suite = MyTestSuite


@pytest.mark.parametrize('runner_cls_name,test_runner_cls,test_suite_cls', [
    ('django.test.runner.DiscoverRunner',
        unittest.TextTestRunner, unittest.TestSuite),
    (to_dotted_name(MyDjangoTestRunner),
        MyTestRunner, MyTestSuite),
], ids=['vanilla runner', 'custom runner'])
def test_runner_keeps_default_classes_in_inheritance_chain(
        settings, runner_cls_name, test_runner_cls, test_suite_cls):
    settings.TEST_RUNNER = runner_cls_name
    django_runner_cls = get_runner(settings)

    def assert_is_djpt_mixin(cls, base_cls, mixin_base_name):
        fullname = 'django_performance_testing.test_runner.{}'.format(
            mixin_base_name)
        mixin_cls_name = '{}Mixin'.format(mixin_base_name)

# Path: django_performance_testing/test_runner.py
# class DjptDjangoTestRunnerMixin(object):
# class DjptTestRunnerMixin(object):
#     class DjptTestRunner(DjptTestRunnerMixin, test_runner_cls.test_runner):
#     class DjptDjangoTestRunner(DjptDjangoTestRunnerMixin, test_runner_cls):
#     def run(self, *a, **kw):
# def wrap_cls_method(cls, method_name, collector_id, ctx_key, is_cls_method):
# def get_runner_with_djpt_mixin(*a, **kw):
#     def addTest(suite_self, test):
#     def fn_to_id(fn):
# def integrate_into_django_test_runner():
# 
# Path: django_performance_testing/serializer.py
# class Reader:
#     def __init__(self, fpath):
#         self.fpath = fpath
# 
#     def read_all(self):
#         with open(self.fpath, 'rb') as f:
#             data = f.read()
#         if not data:
#             return []
#         deserialized = pickle.loads(data)
#         for (sender, results, context) in deserialized:
#             results_read.send(sender=sender, results=results, context=context)
#         return deserialized


# Path: tests/testapp/tests/test_integrates_with_django_testrunner.py
from datetime import timedelta
from django.contrib.auth.models import Group
from django.test.utils import get_runner
from django.utils import six
from django_performance_testing import test_runner as djpt_test_runner_module
from django_performance_testing.serializer import Reader
from freezegun import freeze_time
from testapp.test_helpers import (override_current_context,
                                  run_testcases_with_django_runner)
import pytest
import unittest
import re

class MyTestSuite(object):

    def addTest(self, test):
        pass


class MyTestRunner(object):
    pass


class MyDjangoTestRunner(object):
    test_runner = MyTestRunner
    test_suite = MyTestSuite


@pytest.mark.parametrize('runner_cls_name,test_runner_cls,test_suite_cls', [
    ('django.test.runner.DiscoverRunner',
        unittest.TextTestRunner, unittest.TestSuite),
    (to_dotted_name(MyDjangoTestRunner),
        MyTestRunner, MyTestSuite),
], ids=['vanilla runner', 'custom runner'])
def test_runner_keeps_default_classes_in_inheritance_chain(
        settings, runner_cls_name, test_runner_cls, test_suite_cls):
    settings.TEST_RUNNER = runner_cls_name
    django_runner_cls = get_runner(settings)

    def assert_is_djpt_mixin(cls, base_cls, mixin_base_name):
        fullname = 'django_performance_testing.test_runner.{}'.format(
            mixin_base_name)
        mixin_cls_name = '{}Mixin'.format(mixin_base_name)

        mixin_cls = getattr(djpt_test_runner_module, mixin_cls_name)