Skip to content

Commit e227a41

Browse files
committed
test: test async method powerup
1 parent 5105b77 commit e227a41

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/stdlib_basics/test_session.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from mellea.stdlib.chat import Message
1010
from mellea.stdlib.session import start_session, MelleaSession
1111

12+
import time
1213

1314
# We edit the context type in the async tests below. Don't change the scope here.
1415
@pytest.fixture(scope="function")
@@ -138,18 +139,29 @@ class TestPowerup:
138139
def hello(m:MelleaSession):
139140
return "hello"
140141

142+
async def ahello(m:MelleaSession):
143+
time.sleep(3)
144+
return "hello"
145+
146+
141147
class TestPowerupInherit(TestPowerup):
142148
def hello2(m:MelleaSession):
143149
return "hello"
144150

145151

146-
def test_powerup(m_session):
152+
async def test_powerup(m_session):
153+
154+
MelleaSession.powerup(TestPowerup)
155+
156+
assert "hello" == m_session.hello()
157+
assert "hello" == await m_session.ahello()
147158

148159
MelleaSession.powerup(TestPowerupInherit)
149160

150161
assert "hello" == m_session.hello() # check the inheritance is respected
151162
assert "hello" == m_session.hello2()
152163

153164

165+
154166
if __name__ == "__main__":
155167
pytest.main([__file__])

0 commit comments

Comments
 (0)