mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-16 02:50:48 +00:00
🐛 fix single_session bug
This commit is contained in:
28
tests/test_single_session.py
Normal file
28
tests/test_single_session.py
Normal file
@ -0,0 +1,28 @@
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
import pytest
|
||||
|
||||
from utils import make_fake_event
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_matcher_mutex():
|
||||
from nonebot.plugins.single_session import matcher_mutex
|
||||
|
||||
am = asynccontextmanager(matcher_mutex)
|
||||
event = make_fake_event()()
|
||||
event_1 = make_fake_event()()
|
||||
event_2 = make_fake_event(_session_id="test1")()
|
||||
|
||||
async with am(event) as ctx:
|
||||
assert ctx == False
|
||||
|
||||
async with am(event) as ctx:
|
||||
async with am(event_1) as ctx_1:
|
||||
assert ctx == False
|
||||
assert ctx_1 == True
|
||||
|
||||
async with am(event) as ctx:
|
||||
async with am(event_2) as ctx_2:
|
||||
assert ctx == False
|
||||
assert ctx_2 == False
|
Reference in New Issue
Block a user