mirror of
https://github.com/Steffo99/async-chain.git
synced 2024-11-21 12:34:23 +00:00
❔ Add a getitem test
This commit is contained in:
parent
6511da99f2
commit
361c310ec6
1 changed files with 12 additions and 2 deletions
|
@ -23,6 +23,11 @@ class ExampleClass:
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
return self.__class__(self.value + 1)
|
return self.__class__(self.value + 1)
|
||||||
|
|
||||||
|
@async_chain.method
|
||||||
|
async def triple_list(self):
|
||||||
|
await asyncio.sleep(0)
|
||||||
|
return [self.value, self.value + 1, self.value + 2]
|
||||||
|
|
||||||
|
|
||||||
async def test_class_creation():
|
async def test_class_creation():
|
||||||
example = ExampleClass(0)
|
example = ExampleClass(0)
|
||||||
|
@ -36,9 +41,8 @@ def example():
|
||||||
|
|
||||||
async def test_method_existence(example):
|
async def test_method_existence(example):
|
||||||
assert hasattr(example, "plus")
|
assert hasattr(example, "plus")
|
||||||
assert hasattr(example, "minus")
|
|
||||||
assert hasattr(example, "incremented")
|
assert hasattr(example, "incremented")
|
||||||
assert hasattr(example, "decremented")
|
assert hasattr(example, "triple_list")
|
||||||
|
|
||||||
|
|
||||||
async def test_chain_single_property(example):
|
async def test_chain_single_property(example):
|
||||||
|
@ -63,3 +67,9 @@ async def test_chain_multiple_methods(example):
|
||||||
three = await example.plus(1).plus(1).plus(1)
|
three = await example.plus(1).plus(1).plus(1)
|
||||||
assert isinstance(three, ExampleClass)
|
assert isinstance(three, ExampleClass)
|
||||||
assert three.value == 3
|
assert three.value == 3
|
||||||
|
|
||||||
|
|
||||||
|
async def test_chain_getitem(example):
|
||||||
|
two = await example.triple_list()[2]
|
||||||
|
assert isinstance(two, int)
|
||||||
|
assert two == 2
|
||||||
|
|
Loading…
Reference in a new issue