repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | {"test2": 2} | assert | collection | tests/test_compat.py | test_model_dump | 81 | null | |
nonebot/nonebot2 | import pytest
from nonebot.adapters import MessageTemplate
from utils import FakeMessage, FakeMessageSegment, escape_text
def test_template_message():
template = FakeMessage.template("{a:custom}{b:text}{c:image}/{d}")
@template.add_format_spec
def custom(input: str) -> str:
return f"{input}-custo... | ValueError, match="already exists") | pytest.raises | complex_expr | tests/test_adapters/test_template.py | test_template_message | 20 | null | |
nonebot/nonebot2 | from collections.abc import Callable
import pytest
import nonebot
from nonebot.adapters import Event
from nonebot.matcher import Matcher, matchers
from nonebot.rule import (
CommandRule,
EndswithRule,
FullmatchRule,
IsTypeRule,
KeywordsRule,
RegexRule,
ShellCommandRule,
StartswithRule,... | module | assert | variable | tests/test_plugin/test_on.py | test_on | 146 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_get_driver(monkeypatch: pytest.MonkeyPatch):
with monkeypatch.... | ValueError, match="initialized") | pytest.raises | complex_expr | tests/test_init.py | test_get_driver | 40 | null | |
nonebot/nonebot2 | from contextlib import asynccontextmanager
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.drivers import (
URL,
Driver,
HTTPServerSetup,
Request,
Response,
WebSocket,
WebSocketServerSetup,
)
from utils import FakeAdapter
@pytest.mark.parametrize(
"... | setup | assert | variable | tests/test_adapters/test_adapter.py | test_adapter_server | 106 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_get_bot(app: App, monkeypatch: pytest.MonkeyPatch):
driver = g... | {"test": "test"} | assert | collection | tests/test_init.py | test_get_bot | 101 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | TestModel(test=1) | assert | func_call | tests/test_compat.py | test_custom_validation | 136 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | "123" | assert | string_literal | tests/test_compat.py | test_field_validator | 55 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | msg | assert | variable | tests/test_rule.py | test_startswith | 178 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
from nonebot.exception import SkippedException
from nonebot.permission import (
MESSAGE,
METAEVENT,
NOTICE,
REQUEST,
SUPERUSER,
USER,
Message,
MetaEvent,
Notice,
Permission,
Request,
SuperUser,
User,
)
from utils import make_fake... | expected | assert | variable | tests/test_permission.py | test_message | 64 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | 2 | assert | numeric_literal | tests/test_matcher/test_matcher.py | test_matcher_preset | 175 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_message_validate():
assert type_validate_python(FakeMessage, FakeMessage([])) == | FakeMessage([]) | assert | func_call | tests/test_adapters/test_message.py | test_message_validate | 153 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | parent_plugin | assert | variable | tests/test_plugin/test_load.py | test_load_nested_plugin | 82 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_segment_copy():
origin = FakeMessageSegment.text("text")
copy = origin.copy()
assert origin is... | copy | assert | variable | tests/test_adapters/test_message.py | test_segment_copy | 90 | null | |
nonebot/nonebot2 | import pytest
from nonebot.adapters import MessageTemplate
from utils import FakeMessage, FakeMessageSegment, escape_text
def test_malformed_template():
positive_template = FakeMessage.template("{a}{b}")
message = positive_template.format(a="a", b="b")
assert message.extract_plain_text() == | "ab" | assert | string_literal | tests/test_adapters/test_template.py | test_malformed_template | 63 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_get_app():
driver = get_driver()
assert isinstance(driver,... | driver.server_app | assert | complex_expr | tests/test_init.py | test_get_app | 55 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | False | assert | bool_literal | tests/test_rule.py | test_rule | 76 | null | |
nonebot/nonebot2 | from pydantic import BaseModel, Field
import pytest
import nonebot
from nonebot.plugin import PluginManager, _managers
def test_get_plugin():
# check simple plugin
plugin = nonebot.get_plugin("export")
assert plugin
assert plugin.id_ == "export"
assert plugin.name == "export"
assert plugin.mo... | "plugins.export" | assert | string_literal | tests/test_plugin/test_get.py | test_get_plugin | 14 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | expected | assert | variable | tests/test_plugin/test_load.py | test_inherit_supported_adapters_combine | 267 | null | |
nonebot/nonebot2 | from http.cookies import SimpleCookie
import json
from typing import Any
from aiohttp import ClientSession, ClientWebSocketResponse, WSMessage, WSMsgType
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.dependencies import Dependent
from nonebot.drivers import (
URL... | [] | assert | collection | tests/test_driver.py | _startup1 | 44 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
@pytest.mark.anyio
async def test_get_adapter(app: App, monkeypatch: pytest... | adapter | assert | variable | tests/test_init.py | test_get_adapter | 67 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_segment_data():
assert len(FakeMessageSegment.text("text")) == 4
assert FakeMessageSegment.text("te... | ["type", "data"] | assert | collection | tests/test_adapters/test_message.py | test_segment_data | 12 | null | |
nonebot/nonebot2 | from collections.abc import Callable
import pytest
import nonebot
from nonebot.adapters import Event
from nonebot.matcher import Matcher, matchers
from nonebot.rule import (
CommandRule,
EndswithRule,
FullmatchRule,
IsTypeRule,
KeywordsRule,
RegexRule,
ShellCommandRule,
StartswithRule,... | plugin | assert | variable | tests/test_plugin/test_on.py | test_on | 144 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
@pytest.mark.anyio
async def test_get_adapter(app: App, monkeypatch: pytest... | ValueError, match="registered") | pytest.raises | complex_expr | tests/test_init.py | test_get_adapter | 69 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_with_env():
config = Example(_env_file=(".env", ".env.example"))
as... | 123 | assert | numeric_literal | tests/test_config.py | test_config_with_env | 66 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | True | assert | bool_literal | tests/test_matcher/test_matcher.py | test_matcher_info | 23 | null | |
nonebot/nonebot2 | import pytest
from nonebot.adapters import MessageTemplate
from utils import FakeMessage, FakeMessageSegment, escape_text
def test_template_message():
template = FakeMessage.template("{a:custom}{b:text}{c:image}/{d}")
@template.add_format_spec
def custom(input: str) -> str:
return f"{input}-custo... | formatted | assert | variable | tests/test_adapters/test_template.py | test_template_message | 31 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | "allow" | assert | string_literal | tests/test_compat.py | test_default_config | 23 | null | |
nonebot/nonebot2 | from contextlib import suppress
import re
import sys
from exceptiongroup import BaseExceptionGroup
from nonebug import App
import pytest
from nonebot.consts import (
ARG_KEY,
CMD_ARG_KEY,
CMD_KEY,
CMD_START_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_K... | [1, 1] | assert | collection | tests/test_param.py | test_depend | 83 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated
import anyio
from pydantic import Field
from nonebot import on_message
from nonebot.adapters import Bot
from nonebot.params import Depends
test_depends = on_message()
runned = []
def dependency():
runned.append(1)
return 1
def parameterless():... | 0 | assert | numeric_literal | tests/plugins/param/param_depend.py | parameterless | 22 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | pm | assert | variable | tests/test_plugin/test_load.py | _patched_load | 139 | null | |
nonebot/nonebot2 | import pytest
from nonebot.adapters import MessageTemplate
from utils import FakeMessage, FakeMessageSegment, escape_text
def test_rich_template_message():
pic1, pic2, pic3 = (
FakeMessageSegment.image("file:///pic1.jpg"),
FakeMessageSegment.image("file:///pic2.jpg"),
FakeMessageSegment.im... | "[fake:image]" + escape_text("[fake:image]") + "[fake:image]" + "[fake:image]" | assert | string_literal | tests/test_adapters/test_template.py | test_rich_template_message | 48 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_error_env():
with pytest.MonkeyPatch().context() as m:
m.setenv... | SettingsError) | pytest.raises | variable | tests/test_config.py | test_config_error_env | 113 | null | |
nonebot/nonebot2 | from http.cookies import SimpleCookie
import json
from typing import Any
from aiohttp import ClientSession, ClientWebSocketResponse, WSMessage, WSMsgType
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.dependencies import Dependent
from nonebot.drivers import (
URL... | [2] | assert | collection | tests/test_driver.py | _shutdown1 | 65 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def mock_run(*args, **kwargs):
nonlocal runned
runned =... | {"kwarg": "kwarg"} | assert | collection | tests/test_init.py | mock_run | 80 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | RuntimeError) | pytest.raises | variable | tests/test_plugin/test_load.py | test_load_plugins | 69 | null | |
nonebot/nonebot2 | from typing import Any
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.exception import MockApiException
@pytest.mark.anyio
async def test_bot_called_api_hook_simple(app: App):
runned: bool = False
async def called_api_hook(
bot: Bot,
exceptio... | {called_api_hook} | assert | collection | tests/test_adapters/test_bot.py | test_bot_called_api_hook_simple | 141 | null | |
nonebot/nonebot2 | from contextlib import asynccontextmanager
import pytest
from utils import make_fake_event
@pytest.mark.anyio
async def test_matcher_mutex():
from nonebot.plugins.single_session import _running_matcher, matcher_mutex
am = asynccontextmanager(matcher_mutex)
event = make_fake_event()()
event_1 = make_... | True | assert | bool_literal | tests/test_single_session.py | test_matcher_mutex | 25 | null | |
nonebot/nonebot2 | from contextlib import suppress
import re
import sys
from exceptiongroup import BaseExceptionGroup
from nonebug import App
import pytest
from nonebot.consts import (
ARG_KEY,
CMD_ARG_KEY,
CMD_KEY,
CMD_START_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_K... | ValueError, match=UNKNOWN_PARAM) | pytest.raises | complex_expr | tests/test_param.py | test_bot | 211 | null | |
nonebot/nonebot2 | from pydantic import BaseModel, Field
import pytest
import nonebot
from nonebot.plugin import PluginManager, _managers
def test_get_plugin():
# check simple plugin
plugin = nonebot.get_plugin("export")
assert plugin
assert plugin.id_ == | "export" | assert | string_literal | tests/test_plugin/test_get.py | test_get_plugin | 12 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | cmds | assert | variable | tests/test_rule.py | test_command | 337 | null | |
nonebot/nonebot2 | from collections.abc import Callable
import pytest
import nonebot
from nonebot.adapters import Event
from nonebot.matcher import Matcher, matchers
from nonebot.rule import (
CommandRule,
EndswithRule,
FullmatchRule,
IsTypeRule,
KeywordsRule,
RegexRule,
ShellCommandRule,
StartswithRule,... | state | assert | variable | tests/test_plugin/test_on.py | test_on | 142 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | 2 | assert | numeric_literal | tests/test_compat.py | test_type_adapter | 64 | null | |
nonebot/nonebot2 | from pydantic import BaseModel, Field
import pytest
import nonebot
from nonebot.plugin import PluginManager, _managers
def test_get_plugin_config_with_env(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setenv("PLUGIN_CONFIG_ONE", "no_dummy_val")
monkeypatch.setenv("PLUGIN_SUB_CONFIG__TWO", "two")
monkeypat... | 33 | assert | numeric_literal | tests/test_plugin/test_get.py | test_get_plugin_config_with_env | 93 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | num_managers | assert | variable | tests/test_plugin/test_load.py | test_require_not_loaded | 151 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_segment_data():
assert len(FakeMessageSegment.text("text")) == | 4 | assert | numeric_literal | tests/test_adapters/test_message.py | test_segment_data | 10 | null | |
nonebot/nonebot2 | from contextlib import suppress
import re
import sys
from exceptiongroup import BaseExceptionGroup
from nonebug import App
import pytest
from nonebot.consts import (
ARG_KEY,
CMD_ARG_KEY,
CMD_KEY,
CMD_START_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_K... | (TypeMisMatch, BaseExceptionGroup)) | pytest.raises | collection | tests/test_param.py | test_bot | 219 | null | |
nonebot/nonebot2 | import json
from typing import ClassVar, Dict, List, Literal, TypeVar, Union # noqa: UP035
from nonebot.utils import (
DataclassEncoder,
escape_tag,
generic_check_issubclass,
is_async_gen_callable,
is_coroutine_callable,
is_gen_callable,
)
from utils import FakeMessage, FakeMessageSegment
def... | r"\<red>red\</red>" | assert | complex_expr | tests/test_utils.py | test_loguru_escape_tag | 16 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | sys.modules | assert | complex_expr | tests/test_plugin/test_load.py | test_load_plugins | 59 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | True | assert | bool_literal | tests/test_compat.py | test_default_config | 24 | null | |
nonebot/nonebot2 | from typing import Any
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.exception import MockApiException
@pytest.mark.anyio
async def test_bot_calling_api_hook_simple(app: App):
runned: bool = False
async def calling_api_hook(bot: Bot, api: str, data: dict[st... | {calling_api_hook} | assert | collection | tests/test_adapters/test_bot.py | test_bot_calling_api_hook_simple | 42 | null | |
nonebot/nonebot2 | from contextlib import suppress
import re
import sys
from exceptiongroup import BaseExceptionGroup
from nonebug import App
import pytest
from nonebot.consts import (
ARG_KEY,
CMD_ARG_KEY,
CMD_KEY,
CMD_START_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_K... | 1 | assert | numeric_literal | tests/test_param.py | test_depend | 73 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | {"dynamic.require_not_declared"} | assert | collection | tests/test_plugin/test_load.py | test_require_not_declared | 161 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | 0 | assert | numeric_literal | tests/test_matcher/test_matcher.py | test_matcher_destroy | 209 | null | |
nonebot/nonebot2 | from contextlib import suppress
import re
import sys
from exceptiongroup import BaseExceptionGroup
from nonebug import App
import pytest
from nonebot.consts import (
ARG_KEY,
CMD_ARG_KEY,
CMD_KEY,
CMD_START_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_K... | 2 | assert | numeric_literal | tests/test_param.py | test_depend | 156 | null | |
nonebot/nonebot2 | from contextlib import asynccontextmanager
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.drivers import (
URL,
Driver,
HTTPServerSetup,
Request,
Response,
WebSocket,
WebSocketServerSetup,
)
from utils import FakeAdapter
@pytest.mark.anyio
@pytest.mark... | request | assert | variable | tests/test_adapters/test_adapter.py | test_adapter_http_client | 157 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_with_env():
config = Example(_env_file=(".env", ".env.example"))
as... | 1 | assert | numeric_literal | tests/test_config.py | test_config_with_env | 74 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
from nonebot.exception import SkippedException
from nonebot.permission import (
MESSAGE,
METAEVENT,
NOTICE,
REQUEST,
SUPERUSER,
USER,
Message,
MetaEvent,
Notice,
Permission,
Request,
SuperUser,
User,
)
from utils import make_fake... | True | assert | bool_literal | tests/test_permission.py | test_permission | 49 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_message_getitem():
message = FakeMessage(
[
FakeMessageSegment.text("test"),
... | 1 | assert | numeric_literal | tests/test_adapters/test_message.py | test_message_getitem | 143 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_no_env():
config = Example(_env_file=None)
assert config.simple == ... | AttributeError) | pytest.raises | variable | tests/test_config.py | test_config_no_env | 58 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_without_delimiter():
config = ExampleWithoutDelimiter()
assert conf... | 3 | assert | numeric_literal | tests/test_config.py | test_config_without_delimiter | 123 | null | |
nonebot/nonebot2 | import pytest
from nonebot.adapters import MessageTemplate
from utils import FakeMessage, FakeMessageSegment, escape_text
def test_template_basis():
template = MessageTemplate("{key:.3%}")
formatted = template.format(key=0.123456789)
assert formatted == | "12.346%" | assert | string_literal | tests/test_adapters/test_template.py | test_template_basis | 10 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | "test" | assert | string_literal | tests/test_compat.py | test_field_info | 32 | null | |
nonebot/nonebot2 | from nonebot import on_message
from nonebot.adapters import Event, Message
from nonebot.matcher import Matcher
from nonebot.params import ArgStr, EventMessage, LastReceived, Received
test_handle = on_message()
async def handle():
await test_handle.finish("send", at_sender=True)
async def got(key1: str = ArgStr()... | y | assert | variable | tests/plugins/matcher/matcher_process.py | receive | 37 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_segment_data():
assert len(FakeMessageSegment.text("text")) == 4
assert FakeMessageSegment.text("t... | {"text": "text"} | assert | collection | tests/test_adapters/test_message.py | test_segment_data | 11 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_segment_validate():
assert type_validate_python(
FakeMessageSegment,
{"type": "text", "... | ValidationError) | pytest.raises | variable | tests/test_adapters/test_message.py | test_segment_validate | 55 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | {"test1": 1} | assert | collection | tests/test_compat.py | test_model_dump | 80 | null | |
nonebot/nonebot2 | from nonebug import App
from nonebot.matcher import DEFAULT_PROVIDER_CLASS, matchers
def test_manager(app: App):
try:
default_provider = matchers.provider
matchers.set_provider(DEFAULT_PROVIDER_CLASS)
assert default_provider == | matchers.provider | assert | complex_expr | tests/test_matcher/test_provider.py | test_manager | 10 | null | |
nonebot/nonebot2 | from contextlib import asynccontextmanager
import pytest
from utils import make_fake_event
@pytest.mark.anyio
async def test_matcher_mutex():
from nonebot.plugins.single_session import _running_matcher, matcher_mutex
am = asynccontextmanager(matcher_mutex)
event = make_fake_event()()
event_1 = make_... | False | assert | bool_literal | tests/test_single_session.py | test_matcher_mutex | 19 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_init():
env = nonebot.get_driver().env
assert env == "test... | "new" | assert | string_literal | tests/test_init.py | test_init | 28 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | 1 | assert | numeric_literal | tests/test_matcher/test_matcher.py | test_matcher_info | 20 | null | |
nonebot/nonebot2 | from nonebot.plugin import PluginManager, _managers
def test_load_plugin_name():
m = PluginManager(plugins=["dynamic.manager"])
try:
_managers.append(m)
# load by plugin id
module1 = m.load_plugin("manager")
# load by module name
module2 = m.load_plugin("dynamic.manager... | module2 | assert | variable | tests/test_plugin/test_manager.py | test_load_plugin_name | 15 | null | |
nonebot/nonebot2 | from typing import TYPE_CHECKING
from pydantic import BaseModel, Field
import pytest
from nonebot.compat import PYDANTIC_V2, LegacyUnionField
from nonebot.config import DOTENV_TYPE, BaseSettings, SettingsConfig, SettingsError
def test_config_no_env():
config = Example(_env_file=None)
assert config.simple ==... | "" | assert | string_literal | tests/test_config.py | test_config_no_env | 57 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | None | assert | none_literal | tests/test_matcher/test_matcher.py | test_matcher_info | 22 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_get_asgi():
driver = get_driver()
assert isinstance(driver... | driver.asgi | assert | complex_expr | tests/test_init.py | test_get_asgi | 48 | null | |
nonebot/nonebot2 | import sys
from nonebug import App
import pytest
from nonebot import on_message
from nonebot.adapters import Bot, Event
from nonebot.exception import IgnoredException
from nonebot.log import default_filter, default_format, logger
from nonebot.matcher import Matcher
import nonebot.message as message
from nonebot.messa... | { dependent.call for dependent in message._event_postprocessors } | assert | collection | tests/test_broadcast.py | test_event_postprocessor | 152 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_message_getitem():
message = FakeMessage(
[
FakeMessageSegment.text("test"),
... | 0 | assert | numeric_literal | tests/test_adapters/test_message.py | test_message_getitem | 142 | null | |
nonebot/nonebot2 | import sys
from nonebug import App
import pytest
from nonebot import on_message
from nonebot.adapters import Bot, Event
from nonebot.exception import IgnoredException
from nonebot.log import default_filter, default_format, logger
from nonebot.matcher import Matcher
import nonebot.message as message
from nonebot.messa... | capsys.readouterr().out | assert | func_call | tests/test_broadcast.py | test_event_preprocessor_exception | 131 | null | |
nonebot/nonebot2 | from pydantic import BaseModel, Field
import pytest
import nonebot
from nonebot.plugin import PluginManager, _managers
def test_get_available_plugin():
old_managers = _managers.copy()
_managers.clear()
try:
_managers.append(PluginManager(["plugins.export", "plugin.require"]))
# check get ... | {"export", "require"} | assert | collection | tests/test_plugin/test_get.py | test_get_available_plugin | 57 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
from nonebot.exception import SkippedException
from nonebot.permission import (
MESSAGE,
METAEVENT,
NOTICE,
REQUEST,
SUPERUSER,
USER,
Message,
MetaEvent,
Notice,
Permission,
Request,
SuperUser,
User,
)
from utils import make_fake... | False | assert | bool_literal | tests/test_permission.py | test_permission | 48 | null | |
nonebot/nonebot2 | from http.cookies import SimpleCookie
import json
from typing import Any
from aiohttp import ClientSession, ClientWebSocketResponse, WSMessage, WSMsgType
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.dependencies import Dependent
from nonebot.drivers import (
URL... | [2, 1] | assert | collection | tests/test_driver.py | test_lifespan | 77 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | [1, 2] | assert | collection | tests/test_compat.py | test_custom_validation | 137 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def test_get_bot(app: App, monkeypatch: pytest.MonkeyPatch):
driver = g... | ValueError, match="no bots") | pytest.raises | complex_expr | tests/test_init.py | test_get_bot | 94 | null | |
nonebot/nonebot2 | from typing import Any
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.exception import MockApiException
@pytest.mark.anyio
async def test_bot_calling_api_hook_multi_mock(app: App):
runned1: bool = False
runned2: bool = False
event = anyio.Event()
asy... | 1 | assert | numeric_literal | tests/test_adapters/test_bot.py | test_bot_calling_api_hook_multi_mock | 117 | null | |
nonebot/nonebot2 | from http.cookies import SimpleCookie
import json
from typing import Any
from aiohttp import ClientSession, ClientWebSocketResponse, WSMessage, WSMsgType
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.dependencies import Dependent
from nonebot.drivers import (
URL... | [1, 2] | assert | collection | tests/test_driver.py | test_lifespan | 74 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | True | assert | bool_literal | tests/test_rule.py | test_rule | 77 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | None | assert | none_literal | tests/test_plugin/test_load.py | test_load_plugin | 49 | null | |
nonebot/nonebot2 | import sys
from nonebug import App
import pytest
from nonebot import on_message
from nonebot.adapters import Bot, Event
from nonebot.exception import IgnoredException
from nonebot.log import default_filter, default_format, logger
from nonebot.matcher import Matcher
import nonebot.message as message
from nonebot.messa... | { dependent.call for dependent in message._run_preprocessors } | assert | collection | tests/test_broadcast.py | test_run_preprocessor | 225 | null | |
nonebot/nonebot2 | from typing import Any
import anyio
from nonebug import App
import pytest
from nonebot.adapters import Bot
from nonebot.exception import MockApiException
@pytest.mark.anyio
async def test_bot_calling_api_hook_mock(app: App):
runned: bool = False
async def calling_api_hook(bot: Bot, api: str, data: dict[str,... | False | assert | bool_literal | tests/test_adapters/test_bot.py | test_bot_calling_api_hook_mock | 77 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | None | assert | none_literal | tests/test_rule.py | test_regex | 511 | null | |
nonebot/nonebot2 | from pathlib import Path
import sys
from nonebug import App
import pytest
from nonebot import get_plugin
from nonebot.matcher import Matcher, matchers
from nonebot.message import _check_matcher, check_and_run_matcher
from nonebot.permission import Permission, User
from nonebot.rule import Rule
from utils import FakeM... | 3 | assert | numeric_literal | tests/test_matcher/test_matcher.py | test_matcher_info | 42 | null | |
nonebot/nonebot2 | from nonebot import on_message
from nonebot.adapters import Event, Message
from nonebot.matcher import Matcher
from nonebot.params import ArgStr, EventMessage, LastReceived, Received
test_handle = on_message()
async def handle():
await test_handle.finish("send", at_sender=True)
@test_got.got("key1", "prompt key1... | "text" | assert | string_literal | tests/plugins/matcher/matcher_process.py | got | 23 | null | |
nonebot/nonebot2 | from pydantic import ValidationError
import pytest
from nonebot.adapters import Message, MessageSegment
from nonebot.compat import type_validate_python
from utils import FakeMessage, FakeMessageSegment
def test_message_contains():
message = FakeMessage(
[
FakeMessageSegment.text("test"),
... | True | assert | bool_literal | tests/test_adapters/test_message.py | test_message_contains | 185 | null | |
nonebot/nonebot2 | from pydantic import BaseModel, Field
import pytest
import nonebot
from nonebot.plugin import PluginManager, _managers
def test_get_plugin():
# check simple plugin
plugin = nonebot.get_plugin("export")
assert plugin
assert plugin.id_ == "export"
assert plugin.name == "export"
assert plugin.mod... | "nested_subplugin" | assert | string_literal | tests/test_plugin/test_get.py | test_get_plugin | 20 | null | |
nonebot/nonebot2 | import re
from re import Match
from nonebug import App
import pytest
from nonebot.consts import (
CMD_ARG_KEY,
CMD_KEY,
CMD_WHITESPACE_KEY,
ENDSWITH_KEY,
FULLMATCH_KEY,
KEYWORD_KEY,
PREFIX_KEY,
REGEX_MATCHED,
SHELL_ARGS,
SHELL_ARGV,
STARTSWITH_KEY,
)
from nonebot.exception ... | expected | assert | variable | tests/test_rule.py | test_startswith | 185 | null | |
nonebot/nonebot2 | from collections.abc import Callable
from dataclasses import asdict
from functools import wraps
from pathlib import Path
import sys
from typing import TypeVar
from typing_extensions import ParamSpec
import pytest
import nonebot
from nonebot.plugin import (
Plugin,
PluginManager,
_managers,
_plugins,
... | {FakeAdapter} | assert | collection | tests/test_plugin/test_load.py | test_plugin_metadata | 187 | null | |
nonebot/nonebot2 | from dataclasses import dataclass
from typing import Annotated, Any
from pydantic import BaseModel, ValidationError
import pytest
from nonebot.compat import (
DEFAULT_CONFIG,
FieldInfo,
PydanticUndefined,
Required,
TypeAdapter,
custom_validation,
field_validator,
model_dump,
model_... | TestModel(test1=1, test2="2", test3=True, test4={}, test5=[], test6=None) | assert | func_call | tests/test_compat.py | test_validate_json | 149 | null | |
nonebot/nonebot2 | import json
from typing import ClassVar, Dict, List, Literal, TypeVar, Union # noqa: UP035
from nonebot.utils import (
DataclassEncoder,
escape_tag,
generic_check_issubclass,
is_async_gen_callable,
is_coroutine_callable,
is_gen_callable,
)
from utils import FakeMessage, FakeMessageSegment
def... | r"\<fg #fff>white\</fg #fff>" | assert | complex_expr | tests/test_utils.py | test_loguru_escape_tag | 17 | null | |
nonebot/nonebot2 | from nonebug import App
import pytest
import nonebot
from nonebot import (
get_adapter,
get_adapters,
get_app,
get_asgi,
get_bot,
get_bots,
get_driver,
)
from nonebot.drivers import ASGIMixin, Driver, ReverseDriver
def mock_run(*args, **kwargs):
nonlocal runned
runned =... | ("arg",) | assert | collection | tests/test_init.py | mock_run | 79 | null | |
nonebot/nonebot2 | import json
from typing import ClassVar, Dict, List, Literal, TypeVar, Union # noqa: UP035
from nonebot.utils import (
DataclassEncoder,
escape_tag,
generic_check_issubclass,
is_async_gen_callable,
is_coroutine_callable,
is_gen_callable,
)
from utils import FakeMessage, FakeMessageSegment
def... | "\\<fg\n#fff>white\\</fg\n#fff>" | assert | string_literal | tests/test_utils.py | test_loguru_escape_tag | 18 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.