# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


import os
import cgi
import time
import pytest
import tabun_api as api
    import urlparse
from io import BytesIO
from tabun_api.compat import urequest, text, text_types, binary, PY2
    from httplib import HTTPMessage
    from http.client import parse_headers
    from urllib import parse as urlparse
                assert ov == value, '%r: expected %r, got %r' % (key, value, ov)

        elif key not in exclude:
            ov = getattr(obj, key)
            if value is True or value is False or value is None:
                assert ov is value, '%r: expected %r, got %r' % (key, value, ov)
            else:
                assert ov is not True and ov is not False and ov is not None, '%r: expected not None and not bool' % key
                assert ov == value, '%r: expected %r, got %r' % (key, value, ov)


def build_response(req_url, result_path, optparams=None):
    # Параметры ответа по умолчанию
    params = {
        'status': 200,
        'status_msg': 'OK',
        'headers': {
            'Content-Type': 'text/html; charset=utf-8',
            'Set-Cookie': [
                'TABUNSESSIONID=abcdef9876543210abcdef9876543210; path=/',
            ]},
        'url': req_url
    }
    # Параметры, переданные тестом
    if optparams:
        optparams = optparams.copy()
        params['headers'].update(optparams.pop('headers', {}))
        params.update(optparams)

    # Само содержимое подделываемого ответа на HTTP-запрос

# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


# Path: test/testutil.py
import os
import cgi
import time
import pytest
import tabun_api as api
    import urlparse
from io import BytesIO
from tabun_api.compat import urequest, text, text_types, binary, PY2
    from httplib import HTTPMessage
    from http.client import parse_headers
    from urllib import parse as urlparse

                assert ov == value, '%r: expected %r, got %r' % (key, value, ov)

        elif key not in exclude:
            ov = getattr(obj, key)
            if value is True or value is False or value is None:
                assert ov is value, '%r: expected %r, got %r' % (key, value, ov)
            else:
                assert ov is not True and ov is not False and ov is not None, '%r: expected not None and not bool' % key
                assert ov == value, '%r: expected %r, got %r' % (key, value, ov)


def build_response(req_url, result_path, optparams=None):
    # Параметры ответа по умолчанию
    params = {
        'status': 200,
        'status_msg': 'OK',
        'headers': {
            'Content-Type': 'text/html; charset=utf-8',
            'Set-Cookie': [
                'TABUNSESSIONID=abcdef9876543210abcdef9876543210; path=/',
            ]},
        'url': req_url
    }
    # Параметры, переданные тестом
    if optparams:
        optparams = optparams.copy()
        params['headers'].update(optparams.pop('headers', {}))
        params.update(optparams)

    # Само содержимое подделываемого ответа на HTTP-запрос

    fp = BytesIO(load_file(result_path) if result_path else params.get('data', b''))