# Path: paco/constant.py
# def constant(value, delay=None):
#     """
#     Returns a coroutine function that when called, always returns
#     the provided value.
# 
#     This function has an alias: `paco.identity`.
# 
#     Arguments:
#         value (mixed): value to constantly return when coroutine is called.
#         delay (int/float): optional return value delay in seconds.
# 
#     Returns:
#         coroutinefunction
# 
#     Usage::
# 
#         coro = paco.constant('foo')
# 
#         await coro()
#         # => 'foo'
#         await coro()
#         # => 'foo'
# 
#     """
#     @asyncio.coroutine
#     def coro():
#         if delay:
#             yield from asyncio.sleep(delay)
#         return value
# 
#     return coro
# 
# def identity(value, delay=None):
#     """
#     Returns a coroutine function that when called, always returns
#     the provided value.
# 
#     This function is an alias to `paco.constant`.
# 
#     Arguments:
#         value (mixed): value to constantly return when coroutine is called.
#         delay (int/float): optional return value delay in seconds.
# 
#     Returns:
#         coroutinefunction
# 
#     Usage::
# 
#         coro = paco.identity('foo')
# 
#         await coro()
#         # => 'foo'
#         await coro()
#         # => 'foo'
# 
#     """
#     return constant(value, delay=delay)
# 
# Path: tests/helpers.py
# def run_in_loop(coro, *args, **kw):
#     loop = asyncio.get_event_loop()
#     if asyncio.iscoroutinefunction(coro) or isfunction(coro):
#         coro = coro(*args, **kw)
#     return loop.run_until_complete(coro)


import time
from paco import constant, identity
from .helpers import run_in_loop
    assert run_in_loop(task) == 'foo'

    task = constant({'foo': 'bar'})
    assert run_in_loop(task) == {'foo': 'bar'}

    task = constant((1, 2, 3))
    assert run_in_loop(task) == (1, 2, 3)

    task = constant(None)
    assert run_in_loop(task) is None


def test_identify():
    task = identity(1)
    assert run_in_loop(task) == 1

    task = identity('foo')
    assert run_in_loop(task) == 'foo'

    task = identity({'foo': 'bar'})
    assert run_in_loop(task) == {'foo': 'bar'}

    task = identity((1, 2, 3))
    assert run_in_loop(task) == (1, 2, 3)

    task = identity(None)
    assert run_in_loop(task) is None


def test_constant_delay():

# Path: paco/constant.py
# def constant(value, delay=None):
#     """
#     Returns a coroutine function that when called, always returns
#     the provided value.
# 
#     This function has an alias: `paco.identity`.
# 
#     Arguments:
#         value (mixed): value to constantly return when coroutine is called.
#         delay (int/float): optional return value delay in seconds.
# 
#     Returns:
#         coroutinefunction
# 
#     Usage::
# 
#         coro = paco.constant('foo')
# 
#         await coro()
#         # => 'foo'
#         await coro()
#         # => 'foo'
# 
#     """
#     @asyncio.coroutine
#     def coro():
#         if delay:
#             yield from asyncio.sleep(delay)
#         return value
# 
#     return coro
# 
# def identity(value, delay=None):
#     """
#     Returns a coroutine function that when called, always returns
#     the provided value.
# 
#     This function is an alias to `paco.constant`.
# 
#     Arguments:
#         value (mixed): value to constantly return when coroutine is called.
#         delay (int/float): optional return value delay in seconds.
# 
#     Returns:
#         coroutinefunction
# 
#     Usage::
# 
#         coro = paco.identity('foo')
# 
#         await coro()
#         # => 'foo'
#         await coro()
#         # => 'foo'
# 
#     """
#     return constant(value, delay=delay)
# 
# Path: tests/helpers.py
# def run_in_loop(coro, *args, **kw):
#     loop = asyncio.get_event_loop()
#     if asyncio.iscoroutinefunction(coro) or isfunction(coro):
#         coro = coro(*args, **kw)
#     return loop.run_until_complete(coro)


# Path: tests/constant_test.py
import time
from paco import constant, identity
from .helpers import run_in_loop

    assert run_in_loop(task) == 'foo'

    task = constant({'foo': 'bar'})
    assert run_in_loop(task) == {'foo': 'bar'}

    task = constant((1, 2, 3))
    assert run_in_loop(task) == (1, 2, 3)

    task = constant(None)
    assert run_in_loop(task) is None


def test_identify():
    task = identity(1)
    assert run_in_loop(task) == 1

    task = identity('foo')
    assert run_in_loop(task) == 'foo'

    task = identity({'foo': 'bar'})
    assert run_in_loop(task) == {'foo': 'bar'}

    task = identity((1, 2, 3))
    assert run_in_loop(task) == (1, 2, 3)

    task = identity(None)
    assert run_in_loop(task) is None


def test_constant_delay():

    task = constant(1, delay=0.5)