# Path: paco/assertions.py
# def assert_corofunction(**kw):
#     """
#     Asserts if a given values are a coroutine function.
# 
#     Arguments:
#         **kw (mixed): value to check if it is an iterable.
# 
#     Raises:
#         TypeError: if assertion fails.
#     """
#     for name, value in kw.items():
#         if not asyncio.iscoroutinefunction(value):
#             raise TypeError(
#                 'paco: {} must be a coroutine function'.format(name))
# 
# def assert_iter(**kw):
#     """
#     Asserts if a given values implements a valid iterable interface.
# 
#     Arguments:
#         **kw (mixed): value to check if it is an iterable.
# 
#     Raises:
#         TypeError: if assertion fails.
#     """
#     for name, value in kw.items():
#         if not isiter(value):
#             raise TypeError(
#                 'paco: {} must be an iterable object'.format(name))
# 
# def isiter(x):
#     """
#     Returns `True` if the given value implements an valid iterable
#     interface.
# 
#     Arguments:
#         x (mixed): value to check if it is an iterable.
# 
#     Returns:
#         bool
#     """
#     return hasattr(x, '__iter__') and not isinstance(x, (str, bytes))
# 
# def iscoro_or_corofunc(x):
#     """
#     Returns ``True`` if the given value is a coroutine or a coroutine function.
# 
#     Arguments:
#         x (mixed): object value to assert.
# 
#     Returns:
#         bool: returns ``True`` if ``x` is a coroutine or coroutine function.
#     """
#     return asyncio.iscoroutinefunction(x) or asyncio.iscoroutine(x)
# 
# def iscallable(x):
#     """
#     Returns `True` if the given value is a callable primitive object.
# 
#     Arguments:
#         x (mixed): value to check.
# 
#     Returns:
#         bool
#     """
#     return any([
#         isfunc(x),
#         asyncio.iscoroutinefunction(x)
#     ])
# 
# def isfunc(x):
#     """
#     Returns `True` if the given value is a function or method object.
# 
#     Arguments:
#         x (mixed): value to check.
# 
#     Returns:
#         bool
#     """
#     return any([
#         inspect.isfunction(x) and not asyncio.iscoroutinefunction(x),
#         inspect.ismethod(x) and not asyncio.iscoroutinefunction(x)
#     ])


import pytest
import asyncio
from paco.assertions import (assert_corofunction,
                             assert_iter, isiter,
                             iscoro_or_corofunc,
                             iscallable, isfunc)
    assert not iscallable(bytes())
    assert not iscallable(True)


def test_isfunc():
    @asyncio.coroutine
    def coro():
        pass

    assert isfunc(test_isfunc)
    assert isfunc(lambda: True)
    assert not isfunc(coro)
    assert not isfunc(tuple())
    assert not isfunc([])
    assert not isfunc('foo')
    assert not isfunc(bytes())
    assert not isfunc(True)


@asyncio.coroutine
def coro(*args, **kw):
    return args, kw


def test_iscoro_or_():
    assert iscoro_or_corofunc(coro)
    assert iscoro_or_corofunc(coro())
    assert not iscoro_or_corofunc(lambda: True)
    assert not iscoro_or_corofunc(None)
    assert not iscoro_or_corofunc(1)

# Path: paco/assertions.py
# def assert_corofunction(**kw):
#     """
#     Asserts if a given values are a coroutine function.
# 
#     Arguments:
#         **kw (mixed): value to check if it is an iterable.
# 
#     Raises:
#         TypeError: if assertion fails.
#     """
#     for name, value in kw.items():
#         if not asyncio.iscoroutinefunction(value):
#             raise TypeError(
#                 'paco: {} must be a coroutine function'.format(name))
# 
# def assert_iter(**kw):
#     """
#     Asserts if a given values implements a valid iterable interface.
# 
#     Arguments:
#         **kw (mixed): value to check if it is an iterable.
# 
#     Raises:
#         TypeError: if assertion fails.
#     """
#     for name, value in kw.items():
#         if not isiter(value):
#             raise TypeError(
#                 'paco: {} must be an iterable object'.format(name))
# 
# def isiter(x):
#     """
#     Returns `True` if the given value implements an valid iterable
#     interface.
# 
#     Arguments:
#         x (mixed): value to check if it is an iterable.
# 
#     Returns:
#         bool
#     """
#     return hasattr(x, '__iter__') and not isinstance(x, (str, bytes))
# 
# def iscoro_or_corofunc(x):
#     """
#     Returns ``True`` if the given value is a coroutine or a coroutine function.
# 
#     Arguments:
#         x (mixed): object value to assert.
# 
#     Returns:
#         bool: returns ``True`` if ``x` is a coroutine or coroutine function.
#     """
#     return asyncio.iscoroutinefunction(x) or asyncio.iscoroutine(x)
# 
# def iscallable(x):
#     """
#     Returns `True` if the given value is a callable primitive object.
# 
#     Arguments:
#         x (mixed): value to check.
# 
#     Returns:
#         bool
#     """
#     return any([
#         isfunc(x),
#         asyncio.iscoroutinefunction(x)
#     ])
# 
# def isfunc(x):
#     """
#     Returns `True` if the given value is a function or method object.
# 
#     Arguments:
#         x (mixed): value to check.
# 
#     Returns:
#         bool
#     """
#     return any([
#         inspect.isfunction(x) and not asyncio.iscoroutinefunction(x),
#         inspect.ismethod(x) and not asyncio.iscoroutinefunction(x)
#     ])


# Path: tests/assertions_test.py
import pytest
import asyncio
from paco.assertions import (assert_corofunction,
                             assert_iter, isiter,
                             iscoro_or_corofunc,
                             iscallable, isfunc)

    assert not iscallable(bytes())
    assert not iscallable(True)


def test_isfunc():
    @asyncio.coroutine
    def coro():
        pass

    assert isfunc(test_isfunc)
    assert isfunc(lambda: True)
    assert not isfunc(coro)
    assert not isfunc(tuple())
    assert not isfunc([])
    assert not isfunc('foo')
    assert not isfunc(bytes())
    assert not isfunc(True)


@asyncio.coroutine
def coro(*args, **kw):
    return args, kw


def test_iscoro_or_():
    assert iscoro_or_corofunc(coro)
    assert iscoro_or_corofunc(coro())
    assert not iscoro_or_corofunc(lambda: True)
    assert not iscoro_or_corofunc(None)
    assert not iscoro_or_corofunc(1)

    assert not iscoro_or_corofunc(True)