# 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

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)):
            req_url = fullurl
        else:
            assert data is None
            data = fullurl.data
            req_url = fullurl.get_full_url()

        # Тестируем совместимость с разными питонами и попутно собираем заголовки
        headers = {}
        if PY2:
            assert isinstance(req_url, binary)
            if req_url is not fullurl:
                for h, v in fullurl.headers.items():
                    assert isinstance(h, binary)
                    assert isinstance(v, binary)
                    headers[h.decode('utf-8').lower()] = v
        else:

# 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


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)):
            req_url = fullurl
        else:
            assert data is None
            data = fullurl.data
            req_url = fullurl.get_full_url()

        # Тестируем совместимость с разными питонами и попутно собираем заголовки
        headers = {}
        if PY2:
            assert isinstance(req_url, binary)
            if req_url is not fullurl:
                for h, v in fullurl.headers.items():
                    assert isinstance(h, binary)
                    assert isinstance(v, binary)
                    headers[h.decode('utf-8').lower()] = v
        else:

            assert isinstance(req_url, text)