# 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
        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)
            if req_url is not fullurl:
                for h, v in fullurl.headers.items():
                    assert isinstance(h, text)
                    assert isinstance(v, binary)  # значение всегда binary
                    headers[h.lower()] = v


        assert data is None or isinstance(data, binary)
        assert timeout is None or isinstance(timeout, (int, float))

        # Потестировали, а дальше проще с юникодом работать
        if PY2:
            req_url = req_url.decode('utf-8')

        # Перехват запроса при необходимости, можно его параметры assert'ить здесь
        for url, func in form_interceptors.items():
            if req_url != url and req_url != api.http_host + url:
                continue
            ctype = headers['content-type'].decode('utf-8')
            if ctype.startswith('multipart/form-data;'):

# 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

        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)
            if req_url is not fullurl:
                for h, v in fullurl.headers.items():
                    assert isinstance(h, text)
                    assert isinstance(v, binary)  # значение всегда binary
                    headers[h.lower()] = v


        assert data is None or isinstance(data, binary)
        assert timeout is None or isinstance(timeout, (int, float))

        # Потестировали, а дальше проще с юникодом работать
        if PY2:
            req_url = req_url.decode('utf-8')

        # Перехват запроса при необходимости, можно его параметры assert'ить здесь
        for url, func in form_interceptors.items():
            if req_url != url and req_url != api.http_host + url:
                continue
            ctype = headers['content-type'].decode('utf-8')
            if ctype.startswith('multipart/form-data;'):

                pdict = cgi.parse_header(headers['content-type'] if PY2 else ctype)[1]