# 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
        if isinstance(value, (tuple, list)):
            raw_headers += ('\r\n' + header + ': ').join(value)
        else:
            raw_headers += value
        raw_headers += '\r\n'
    headers = parse_headers(BytesIO(raw_headers.encode('utf-8')))

    # Для некоторых ошибок нужно сгенерировать исключение
    if (params['status'] >= 500 or params['status'] in (404,)) and not params.get('noexc'):
        raise urequest.HTTPError(params['url'], params['status'], params['status_msg'], headers, fp)

    # Собираем ответ на HTTP-запрос
    resp = urequest.addinfourl(fp, headers, params['url'])
    resp.code = params['status']
    resp.msg = params['status_msg']
    return resp


class UserTest(api.User):
    def __init__(self, *args, **kwargs):
        if 'avoid_cf' not in kwargs:
            kwargs['avoid_cf'] = False  # Чтобы не тратить время на импорт js2py
        self.sleeps = [0, 0.0]
        super(UserTest, self).__init__(*args, **kwargs)

    def sleep_func(self, tm):
        self.sleeps[0] += 1
        self.sleeps[1] += tm

    def test_open(self, fullurl, data=None, timeout=None):

# 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

        if isinstance(value, (tuple, list)):
            raw_headers += ('\r\n' + header + ': ').join(value)
        else:
            raw_headers += value
        raw_headers += '\r\n'
    headers = parse_headers(BytesIO(raw_headers.encode('utf-8')))

    # Для некоторых ошибок нужно сгенерировать исключение
    if (params['status'] >= 500 or params['status'] in (404,)) and not params.get('noexc'):
        raise urequest.HTTPError(params['url'], params['status'], params['status_msg'], headers, fp)

    # Собираем ответ на HTTP-запрос
    resp = urequest.addinfourl(fp, headers, params['url'])
    resp.code = params['status']
    resp.msg = params['status_msg']
    return resp


class UserTest(api.User):
    def __init__(self, *args, **kwargs):
        if 'avoid_cf' not in kwargs:
            kwargs['avoid_cf'] = False  # Чтобы не тратить время на импорт js2py
        self.sleeps = [0, 0.0]
        super(UserTest, self).__init__(*args, **kwargs)

    def sleep_func(self, tm):
        self.sleeps[0] += 1
        self.sleeps[1] += tm

    def test_open(self, fullurl, data=None, timeout=None):

        if isinstance(fullurl, (text, binary)):