# Path: tabun_api/utils.py
# def parse_html(data, encoding='utf-8'):
# def parse_html_fragment(data, encoding='utf-8'):
#     def __init__(self, params=None):
#     def format(self, node, with_cutted=True):
#     def format_part(self, node, with_cutted=True):
#     def element_children(self, item, noblock=False):
#     def process_br(self, item, data, depth, with_cutted):
#     def default_process(self, item, data, depth, with_cutted):
#     def format_item_tail(self, item, data, depth, full_queue):
#     def format_text(self, ntext, data=None):
#     def escape(self, ntext):
#     def process_a(self, item, data, depth, with_cutted):
#     def process_span(self, item, data, depth, with_cutted):
#     def process_li(self, item, data, depth, with_cutted):
#     def process_blockquote(self, item, data, depth, with_cutted):
#     def process_hr(self, item, data, depth, with_cutted):
#     def process_s(self, item, data, depth, with_cutted):
# def htmlToString(node, with_cutted=True, fancy=True, vk_links=False, hr_lines=True, disable_links=False):
# def node2string(node, encoding="utf-8"):
# def mon2num(s):
# def is_cut(item):
# def find_images(body, spoiler_title=True, no_other=False):
# def encode_multipart_formdata(fields, files, boundary=None):
# def get_content_type(filename):
# def send_form(url, fields, files, timeout=None, headers=None):
# def find_substring(s, start, end, extend=False, with_start=True, with_end=True):
# def download(url, maxmem=20 * 1024 * 1024, timeout=5, waitout=15, headers=None):
# def find_good_image(urls, maxmem=20 * 1024 * 1024):
# def generate_comments_tree(comms):
# def parse_avatar_url(url):
# def decode_cf_email(data):
# def decode_cf_email_for_link(m):
# def replace_cloudflare_emails(data):
# def normalize_body(body=None, raw_body=None, cls='text'):
# def html_escape(s, single_quote=False):
# def escape_topic_contents(data, may_be_short=False):
# def escape_comment_contents(data):
# def escape_blog_content(data):
# def escape_profile_content(data):
# def parse_datetime(s, utc=True):
# def gen_user_agent():
# def get_cookies_dict(headers):
# def is_module_available(name):
# def build_proxy_params(proxy=None):
# class HTMLFormatter(object):
#     NEWLINE = -1
#     L = []
# 
# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


import pytest
import lxml.html
    import string
    import random
    import string
    import random
    import socks
    import socks
from tabun_api import utils
from tabun_api.compat import PY2, text, binary
from testutil import user
    from io import BytesIO
        from httplib import HTTPMessage
        from http.client import parse_headers
def test_parse_datetime_2014_03():
    assert utils.parse_datetime('2014-10-26T01:00:00+03:00').strftime('%Y-%m-%d %H:%M:%S') == '2014-10-25 22:00:00'


def test_html_escape_nosingle_str():
    assert utils.html_escape('&lt;"<>\'') == '&amp;lt;&quot;&lt;&gt;\''


def test_html_escape_nosingle_bytes():
    assert utils.html_escape(b'&lt;"<>\'') == b'&amp;lt;&quot;&lt;&gt;\''


def test_html_escape_single_str():
    assert utils.html_escape('&lt;"<>\'', True) == '&amp;lt;&quot;&lt;&gt;&#39;'


def test_html_escape_single_bytes():
    assert utils.html_escape(b'&lt;"<>\'', True) == b'&amp;lt;&quot;&lt;&gt;&#39;'


def test_get_cookies_dict():
    if PY2:
    else:

    fp = BytesIO(
        b'Set-Cookie: a=b; path=/\r\n'
        b'Set-Cookie: c=d; path=/\r\n'
        b'\r\n'
    )


# Path: tabun_api/utils.py
# def parse_html(data, encoding='utf-8'):
# def parse_html_fragment(data, encoding='utf-8'):
#     def __init__(self, params=None):
#     def format(self, node, with_cutted=True):
#     def format_part(self, node, with_cutted=True):
#     def element_children(self, item, noblock=False):
#     def process_br(self, item, data, depth, with_cutted):
#     def default_process(self, item, data, depth, with_cutted):
#     def format_item_tail(self, item, data, depth, full_queue):
#     def format_text(self, ntext, data=None):
#     def escape(self, ntext):
#     def process_a(self, item, data, depth, with_cutted):
#     def process_span(self, item, data, depth, with_cutted):
#     def process_li(self, item, data, depth, with_cutted):
#     def process_blockquote(self, item, data, depth, with_cutted):
#     def process_hr(self, item, data, depth, with_cutted):
#     def process_s(self, item, data, depth, with_cutted):
# def htmlToString(node, with_cutted=True, fancy=True, vk_links=False, hr_lines=True, disable_links=False):
# def node2string(node, encoding="utf-8"):
# def mon2num(s):
# def is_cut(item):
# def find_images(body, spoiler_title=True, no_other=False):
# def encode_multipart_formdata(fields, files, boundary=None):
# def get_content_type(filename):
# def send_form(url, fields, files, timeout=None, headers=None):
# def find_substring(s, start, end, extend=False, with_start=True, with_end=True):
# def download(url, maxmem=20 * 1024 * 1024, timeout=5, waitout=15, headers=None):
# def find_good_image(urls, maxmem=20 * 1024 * 1024):
# def generate_comments_tree(comms):
# def parse_avatar_url(url):
# def decode_cf_email(data):
# def decode_cf_email_for_link(m):
# def replace_cloudflare_emails(data):
# def normalize_body(body=None, raw_body=None, cls='text'):
# def html_escape(s, single_quote=False):
# def escape_topic_contents(data, may_be_short=False):
# def escape_comment_contents(data):
# def escape_blog_content(data):
# def escape_profile_content(data):
# def parse_datetime(s, utc=True):
# def gen_user_agent():
# def get_cookies_dict(headers):
# def is_module_available(name):
# def build_proxy_params(proxy=None):
# class HTMLFormatter(object):
#     NEWLINE = -1
#     L = []
# 
# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


# Path: test/test_utils.py
import pytest
import lxml.html
    import string
    import random
    import string
    import random
    import socks
    import socks
from tabun_api import utils
from tabun_api.compat import PY2, text, binary
from testutil import user
    from io import BytesIO
        from httplib import HTTPMessage
        from http.client import parse_headers

def test_parse_datetime_2014_03():
    assert utils.parse_datetime('2014-10-26T01:00:00+03:00').strftime('%Y-%m-%d %H:%M:%S') == '2014-10-25 22:00:00'


def test_html_escape_nosingle_str():
    assert utils.html_escape('&lt;"<>\'') == '&amp;lt;&quot;&lt;&gt;\''


def test_html_escape_nosingle_bytes():
    assert utils.html_escape(b'&lt;"<>\'') == b'&amp;lt;&quot;&lt;&gt;\''


def test_html_escape_single_str():
    assert utils.html_escape('&lt;"<>\'', True) == '&amp;lt;&quot;&lt;&gt;&#39;'


def test_html_escape_single_bytes():
    assert utils.html_escape(b'&lt;"<>\'', True) == b'&amp;lt;&quot;&lt;&gt;&#39;'


def test_get_cookies_dict():
    if PY2:
    else:

    fp = BytesIO(
        b'Set-Cookie: a=b; path=/\r\n'
        b'Set-Cookie: c=d; path=/\r\n'
        b'\r\n'
    )


    if PY2: