Ejemplo n.º 1
0
async def test_complicating_4():
    def func():
        """t"""

    await complicating(func)()
    assert asyncio.iscoroutinefunction(complicating(func))
    assert complicating(func).__name__ == func.__name__
    assert complicating(func).__doc__ == func.__doc__
Ejemplo n.º 2
0
 def __new__(cls: type, clsname, bases, namespace):
     for name in args:
         if name not in namespace:
             continue
         if name == "test":
             assert namespace[name] is complicating(namespace[name])
         namespace[name] = complicating(namespace[name])
     return type.__new__(cls, clsname, bases, namespace)
Ejemplo n.º 3
0
async def test_complicating_1():
    class AsyncClass:
        def __await__(self):
            return self.dispatch().__await__()

        async def dispatch(self):
            pass

    await AsyncClass()
    assert complicating(AsyncClass) == AsyncClass

    await AsyncClass().dispatch()
    assert complicating(AsyncClass.dispatch) is AsyncClass.dispatch
Ejemplo n.º 4
0
async def test_complicating_3():
    @asyncio.coroutine
    def t():
        pass

    await t()
    assert complicating(t) is t
Ejemplo n.º 5
0
async def test_complicating_0():
    class AsyncCall:
        async def __call__(self):
            pass

    await AsyncCall()()
    asyncfunc = AsyncCall()
    assert complicating(asyncfunc) is asyncfunc
Ejemplo n.º 6
0
    def __post_init__(
            self, method: Literal["",
                                  LOWER_HTTP_METHODS]) -> None:  # type: ignore
        super().__post_init__()
        self.endpoint = complicating(self.endpoint)

        if not (hasattr(self.endpoint, "__methods__")
                or hasattr(self.endpoint, "__method__")):
            if method == "":
                raise ValueError("View function must be marked with method")
            self.endpoint = only_allow(method, self.endpoint)
        else:
            if hasattr(self.endpoint,
                       "__method__") and (method.upper() not in (getattr(
                           self.endpoint, "__method__"), "")):
                raise ValueError("View function has been marked with method")
            if hasattr(self.endpoint, "__methods__") and method != "":
                raise ValueError("View class can't be marked with method")
Ejemplo n.º 7
0
async def test_complicating_2():
    async def async_func():
        pass

    await async_func()
    assert complicating(async_func) is async_func