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 |
|---|---|---|---|---|---|---|---|---|---|
lona-web-org/lona | async def test_click_events(lona_app_context):
from playwright.async_api import async_playwright
state = {
'html': None,
'input-events': [],
}
def setup_app(app):
from lona.html import CLICK, HTML, Div
from lona import View
class OuterDiv(Div):
EVEN... | 'SUCCESS' | assert | string_literal | tests/test_0303_click_events.py | test_click_events | 77 | null | |
lona-web-org/lona | import re
import pytest
from lona.html import Div
def test_get_initial_values():
d = Div(foo='foo', bar='bar')
assert d.attributes['foo'] == | 'foo' | assert | string_literal | tests/test_0101_html_attribute_dict.py | test_get_initial_values | 11 | null | |
lona-web-org/lona | async def test_simple_daemon_view(lona_app_context):
"""
This test tests if a the state a daemonized view is hold by the server over
page refreshes, until the view gets stopped by the user.
"""
from playwright.async_api import async_playwright
from lona.pytest import eventually
def setup_... | 0 | assert | numeric_literal | tests/test_daemon_views.py | test_simple_daemon_view | 97 | null | |
lona-web-org/lona | from lona.html import Widget, Span, Node, Div
from lona.html.text_node import TextNode
def test_sub_nodes():
assert Div(Div()) == Div(Div())
assert Div(Div()) != | Div(Div(a=1)) | assert | func_call | tests/test_0107_html_node_compare.py | test_sub_nodes | 78 | null | |
lona-web-org/lona | import pytest
from lona.html import (
NumberInput,
TextInput,
TextArea,
CheckBox,
Select2,
Option2,
Submit,
Select,
Option,
Button,
HTML2,
HTML1,
Node,
Div,
)
from lona.compat import set_use_future_node_classes
def test_sub_nodes():
node = HTML1("""
... | 'h1' | assert | string_literal | tests/test_0104_html_parsing.py | test_sub_nodes | 61 | null | |
lona-web-org/lona | import pytest
from lona.html import Div
def test_len_returns_number_of_elements():
d = Div(_id='foo bar')
assert len(d.id_list) == | 2 | assert | numeric_literal | tests/test_0102_html_attribute_list.py | test_len_returns_number_of_elements | 107 | null | |
lona-web-org/lona | from lona.html import Widget, Span, Node, Div
from lona.html.text_node import TextNode
def test_non_node_comparisons():
assert Div() != | 'Div' | assert | string_literal | tests/test_0107_html_node_compare.py | test_non_node_comparisons | 38 | null | |
lona-web-org/lona | import pytest
from lona.routing import Router, Route
class TestBasicRouting:
def setup_method(self):
self.routes = [
Route('/foo/<arg>/', None),
Route('/foo/', None),
Route('/bar/<arg>/', None),
Route('/', None),
]
self.router = Router()
... | self.routes[2] | assert | complex_expr | tests/test_0301_routing.py | test_resolve_with_argument_2 | TestBasicRouting | 36 | null |
lona-web-org/lona | import pytest
from lona.html import (
NumberInput,
TextInput,
TextArea,
CheckBox,
Select2,
Option2,
Submit,
Select,
Option,
Button,
HTML2,
HTML1,
Node,
Div,
)
from lona.compat import set_use_future_node_classes
def test_self_closing_tag_with_slash():
img = H... | True | assert | bool_literal | tests/test_0104_html_parsing.py | test_self_closing_tag_with_slash | 148 | null | |
lona-web-org/lona | from lona.html import NumberInput, HTML1
def test_initial_value():
node = NumberInput(value=12.3)
assert node.value == | 12.3 | assert | numeric_literal | tests/test_0201_number_input.py | test_initial_value | 16 | null | |
lona-web-org/lona | async def test_simple_daemon_view(lona_app_context):
"""
This test tests if a the state a daemonized view is hold by the server over
page refreshes, until the view gets stopped by the user.
"""
from playwright.async_api import async_playwright
from lona.pytest import eventually
def setup_... | 'view stopped' | assert | string_literal | tests/test_daemon_views.py | test_simple_daemon_view | 87 | null | |
lona-web-org/lona | import re
import pytest
from lona.html import Div
def test_get_initial_values():
d = Div(foo='foo', bar='bar')
assert d.attributes['foo'] == 'foo'
assert d.attributes['bar'] == | 'bar' | assert | string_literal | tests/test_0101_html_attribute_dict.py | test_get_initial_values | 12 | null | |
lona-web-org/lona | import pytest
from lona.routing import Router, Route
class TestBasicRouting:
def setup_method(self):
self.routes = [
Route('/foo/<arg>/', None),
Route('/foo/', None),
Route('/bar/<arg>/', None),
Route('/', None),
]
self.router = Router()
... | self.routes[3] | assert | complex_expr | tests/test_0301_routing.py | test_resolve_root | TestBasicRouting | 43 | null |
lona-web-org/lona | from lona.html import NumberInput, HTML1
def test_default_properties():
node = NumberInput()
assert node.value is | None | assert | none_literal | tests/test_0201_number_input.py | test_default_properties | 7 | null | |
lona-web-org/lona | def save_message(message_list):
def _save_message(message):
if message.topic.startswith('lona.'):
return
message_list.append(message)
if message.data.get('crash', False):
raise RuntimeError()
return _save_message
def do_nothing(*args, **kwargs):
pass
asyn... | 3 | assert | numeric_literal | tests/test_channels.py | test_view_api | 362 | null | |
lona-web-org/lona | import pytest
from lona.html import RadioButton, RadioGroup, Label, Div
from lona.html.text_node import TextNode
def test_add_button():
# string value pair
radio_group = RadioGroup()
radio_group.add_button('Foo', 10)
assert len(radio_group.nodes) == 2
assert isinstance(radio_group[0], Label)
... | 1 | assert | numeric_literal | tests/test_0204_html_radio_buttons.py | test_add_button | 89 | null | |
lona-web-org/lona | async def test_click_events(lona_app_context):
from playwright.async_api import async_playwright
state = {
'html': None,
'input-events': [],
}
def setup_app(app):
from lona.html import CLICK, HTML, Div
from lona import View
class OuterDiv(Div):
EVEN... | outer_div | assert | variable | tests/test_0303_click_events.py | test_click_events | 85 | null | |
lona-web-org/lona | import os.path
from playwright.async_api import async_playwright
from lona.static_files import StyleSheet, Script
from lona import View
def setup_app(app):
some_existing_file = os.path.basename(__file__)
@app.route('/')
class MyView(View):
STATIC_FILES = [
StyleSheet(
... | html | assert | variable | tests/test_static_files_view.py | test_static_files_view | 67 | null | |
lona-web-org/lona | def test_select():
import pytest
from lona.html import Select, Option
# basic API ###############################################################
select = Select(
values=[
('foo', 'Foo'),
('bar', 'Bar'),
('baz', 'Baz'),
],
)
assert not selec... | 'foo' | assert | string_literal | tests/test_0202_html_select.py | test_select | 25 | null | |
lona-web-org/lona | from lona.html import Tr, Td
def test_number_of_serialize_calls(mocker):
from lona.html import Node
spy = mocker.spy(Node, '_serialize')
tr = Tr()
for i in range(100):
tr.append(Td(i))
assert spy.call_count < | 150 | assert | numeric_literal | tests/test_performance.py | test_number_of_serialize_calls | 14 | null | |
lona-web-org/lona | import pytest
from lona.html import Div
def test_mixed_nodes():
sub_node1 = Div()
sub_node2 = Div()
div = Div(
sub_node1,
'foo',
sub_node2,
'bar',
)
assert len(div) == | 4 | assert | numeric_literal | tests/test_0103_html_sub_nodes.py | test_mixed_nodes | 35 | null | |
lona-web-org/lona | def test_select2():
import pytest
from lona.html import Select2, Option2
# basic API ###############################################################
select = Select2(
Option2('Foo', value='foo'),
Option2('Bar', value='bar'),
Option2('Baz', value='baz'),
)
assert not se... | () | assert | collection | tests/test_0203_html_select2.py | test_select2 | 145 | null | |
lona-web-org/lona | import pytest
from lona.html import HTML1, Span, Div, H1
def test_closest():
html = Div(
Div(
Div(
Span(),
),
_id='foo',
),
)
span = html[0][0][0]
node = span.closest('div#foo')
assert node is | html[0] | assert | complex_expr | tests/test_0105_html_query_selectors.py | test_closest | 99 | null | |
lona-web-org/lona | def test_option2():
from lona.html import Option2
option = Option2('Foo', value='foo')
assert option.get_text() == 'Foo'
assert option.value == | 'foo' | assert | string_literal | tests/test_0203_html_select2.py | test_option2 | 7 | null | |
lona-web-org/lona | def setup_app(app):
from datetime import datetime
from lona import View
@app.route('/')
class HoweView(View):
def handle_request(self, request):
return 'HOME'
@app.route('/daemonized-view/')
class DaemonizedView(View):
def handle_request(self, request):
... | 'Lona' | assert | string_literal | tests/test_title.py | test_title | 38 | null | |
lona-web-org/lona | import pytest
from lona.html import (
NumberInput,
TextInput,
TextArea,
CheckBox,
Select2,
Option2,
Submit,
Select,
Option,
Button,
HTML2,
HTML1,
Node,
Div,
)
from lona.compat import set_use_future_node_classes
def test_select():
node = HTML1("""
<se... | '2' | assert | string_literal | tests/test_0104_html_parsing.py | test_select | 279 | null | |
lona-web-org/lona | import pytest
from lona.html import RadioButton, RadioGroup, Label, Div
from lona.html.text_node import TextNode
def test_values():
# no value
radio_group = RadioGroup(
RadioButton(value='foo'),
RadioButton(value='bar'),
RadioButton(value='baz'),
)
assert radio_group.value is... | 3 | assert | numeric_literal | tests/test_0204_html_radio_buttons.py | test_values | 19 | null | |
lona-web-org/lona | from lona.exceptions import UserAbort
from lona.pytest import eventually
from lona.html import Button
from lona import View
def setup_app(app):
@app.route('/')
class HomeView(View):
def handle_request(self, request):
return 'HOME'
@app.route('/test-view/')
class TestView(View):
... | None | assert | none_literal | tests/test_view_stop_hooks.py | test_view_stop_hooks | 68 | null | |
lona-web-org/lona | async def test_post_requests(lona_app_context):
"""
This test checks if <form>-requests as GET and POST work as intended.
"""
import json
from playwright.async_api import async_playwright
from lona.html import TextInput, Submit, HTML, Form, Div
from lona import View
def setup_app(app... | {} | assert | collection | tests/test_0306_requests.py | test_post_requests | 51 | null | |
lona-web-org/lona | import pytest
from lona.html import Div
def test_sub_node_reset_with_node():
div1 = Div()
div2 = Div()
div1.nodes = div2
assert len(div1.nodes) == 1
assert div1.nodes[0] is | div2 | assert | variable | tests/test_0103_html_sub_nodes.py | test_sub_node_reset_with_node | 129 | null | |
lona-web-org/lona | import pytest
@pytest.mark.parametrize('client_version', [1, 2])
@pytest.mark.parametrize('browser_name', ['chromium', 'firefox', 'webkit'])
async def test_rendering(browser_name, client_version, lona_project_context):
"""
This test tests all client side rendering features, using the rendering
test view in... | '3' | assert | string_literal | tests/test_0304_rendering.py | test_rendering | 137 | null | |
lona-web-org/lona | def save_message(message_list):
def _save_message(message):
if message.topic.startswith('lona.'):
return
message_list.append(message)
if message.data.get('crash', False):
raise RuntimeError()
return _save_message
def do_nothing(*args, **kwargs):
pass
asyn... | message | assert | variable | tests/test_channels.py | test_message_integrity | 121 | null | |
lona-web-org/lona | import re
import pytest
from lona.html import Div
def test_pop_existing_key():
d = Div(foo='foo-val', bar='bar-val')
assert 'foo' in | d.attributes | assert | complex_expr | tests/test_0101_html_attribute_dict.py | test_pop_existing_key | 64 | null | |
lona-web-org/lona | def test_option2():
from lona.html import Option2
option = Option2('Foo', value='foo')
assert option.get_text() == 'Foo'
assert option.value == 'foo'
# selected
option = Option2()
assert not option.selected
assert 'selected' not in | option.attributes | assert | complex_expr | tests/test_0203_html_select2.py | test_option2 | 13 | null | |
lona-web-org/lona | from playwright.async_api import async_playwright
from lona.html import NumberInput, Select, HTML
from lona.pytest import eventually
from lona import View
async def test_number_inputs(lona_app_context):
test_data = {}
def setup_app(app):
@app.route('/')
class NumberInputView(View):
... | 3 | assert | numeric_literal | tests/test_0403_number_input.py | test_number_inputs | 76 | null | |
lona-web-org/lona | import pytest
from lona.html import HTML1, Span, Div, H1
def test_query_selector_all():
html = Div(
Span(),
Div(
Span(),
),
Span(),
)
nodes = html.query_selector_all('span')
assert len(nodes) == 3
assert html[0] in | nodes | assert | variable | tests/test_0105_html_query_selectors.py | test_query_selector_all | 81 | null | |
DisnakeDev/disnake | import pytest
from disnake.http import HTTPClient
@pytest.mark.parametrize(
("url", "encoding", "zlib", "expected"),
[
(
"wss://gateway.discord.com",
"json",
False,
"wss://gateway.discord.com/?v=10&encoding=json",
),
(
"wss://... | expected | assert | variable | tests/test_http.py | test_format_gateway_url | 47 | null | |
DisnakeDev/disnake | from __future__ import annotations
import re
import pytest
from disnake import flags
class TestFlagValue:
def test_flag_value_xor(self) -> None:
ins = TestFlags(one=True, two=True)
ins ^= TestFlags.two
assert ins.value == 1
ins ^= TestFlags.three
assert ins.value == | 2 | assert | numeric_literal | tests/test_flags.py | test_flag_value_xor | TestFlagValue | 147 | null |
DisnakeDev/disnake | import math
import pytest
from disnake import Color, Colour
def test_alias() -> None:
assert Color is | Colour | assert | variable | tests/test_colour.py | test_alias | 61 | null | |
DisnakeDev/disnake | import datetime
from typing import Any
import pytest
from disnake.ext import commands
from disnake.ext.tasks import LF, Loop, loop
class TestLoops:
def test_inheritance(self) -> None:
class HyperLoop(Loop[LF]):
def __init__(self, coro: LF, time_tup: tuple[float, float, float]) -> None:
... | (1, 2, 3) | assert | collection | tests/ext/tasks/test_loops.py | test_inheritance | TestLoops | 66 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | button1 | assert | variable | tests/ui/test_action_row.py | test_pop | TestActionRow | 129 | null |
DisnakeDev/disnake | from disnake.ext import commands
class TestParents:
def _create_cog(self):
class Cog(commands.Cog):
@commands.slash_command()
async def a(self, _) -> None: ...
@a.sub_command()
async def sub(self, _) -> None: ...
@a.sub_command_group()
... | "a" | assert | string_literal | tests/ext/commands/test_slash_core.py | test_qualified_name | TestParents | 33 | null |
DisnakeDev/disnake | from typing import cast
from unittest import mock
import pytest
import disnake
from disnake.abc import GuildChannel
from disnake.utils import MISSING
class TestGuildChannelEdit:
def channel(self) -> mock.Mock:
ch = mock.Mock(GuildChannel, id=123, category_id=456)
ch._state = mock.Mock(http=mock.... | None | assert | none_literal | tests/test_abc.py | test_none | TestGuildChannelEdit | 30 | null |
DisnakeDev/disnake | from __future__ import annotations
from typing import TYPE_CHECKING
from unittest import mock
import pytest
import disnake
from disnake import Interaction, InteractionResponseType as ResponseType # shortcut
from disnake.state import ConnectionState
from disnake.utils import MISSING
class TestInteractionDataResolve... | channel_type in (14, 99) | assert | func_call | tests/interactions/test_base.py | test_channel | TestInteractionDataResolved | 214 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
import pytest
from disnake import activity as _activity
def activity() -> _activity.Activity:
return _activity.Activity()
def game() -> _activity.Game:
return _activity.Game(name="Celeste")
def custom_activity() -> _activity.CustomActivity:
return _activity.CustomActivi... | "hello" | assert | string_literal | tests/test_activity.py | test_text | TestAssets | 57 | null |
DisnakeDev/disnake | import io
from datetime import datetime, timedelta
import pytest
from disnake import Color, Embed, File, embeds
from disnake.utils import MISSING, utcnow
_BASE = {"type": "rich"}
def embed() -> Embed:
time = utcnow() + timedelta(days=42)
return Embed(
type="link",
title="wow",
descri... | 0 | assert | numeric_literal | tests/test_embeds.py | test_attr_proxy | 192 | null | |
DisnakeDev/disnake | import math
import pytest
from disnake import Color, Colour
@pytest.mark.parametrize(
("value", "parts"),
[(0, (0, 0, 0)), (0xA00233, (0xA0, 0x02, 0x33)), (0x123456, (0x12, 0x34, 0x56))],
)
def test_to_rgb(value: int, parts: tuple[int, int, int]) -> None:
c = Colour(value)
assert c.to_rgb() == | parts | assert | variable | tests/test_colour.py | test_to_rgb | 32 | null | |
DisnakeDev/disnake | from __future__ import annotations
import contextlib
from collections.abc import Iterator
from typing import Any, TypeVar
import pytest
from typing_extensions import assert_type
from disnake import ui
from disnake.ui.button import V_co
V = TypeVar("V", bound=ui.View)
I = TypeVar("I", bound=ui.Item)
def create_call... | cls | assert | variable | tests/ui/test_decorators.py | test_cls | TestDecorator | 64 | null |
DisnakeDev/disnake | import datetime
from typing import Any
import pytest
from disnake.ext import commands
from disnake.ext.tasks import LF, Loop, loop
class TestLoops:
def test_decorator(self) -> None:
class Cog(commands.Cog):
@loop(seconds=30, minutes=0, hours=0)
async def task(self) -> None: ...
... | TypeError, match="must be a coroutine function") | pytest.raises | complex_expr | tests/ext/tasks/test_loops.py | test_decorator | TestLoops | 21 | null |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import (
Guild,
Onboarding,
OnboardingPrompt,
OnboardingPromptOption,
OnboardingPromptType,
)
from disnake.types import onboarding as onboarding_types
onboarding_prompt_option_payload: onboarding_types.OnboardingPromptOption = {
"id": "0",
... | [] | assert | collection | tests/test_onboarding.py | test_onboarding | TestOnboarding | 74 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | exp_cmp | assert | variable | tests/ui/test_action_row.py | test_walk_components | TestActionRow | 204 | null |
DisnakeDev/disnake | from __future__ import annotations
import re
import pytest
from disnake import flags
class TestFlagValue:
def test_flag_value_or(self) -> None:
ins = TestFlags.four | TestFlags.one
assert isinstance(ins, TestFlags)
assert ins.value == 5
assert (TestFlags.two | ins).value == 7
... | 21 | assert | numeric_literal | tests/test_flags.py | test_flag_value_or | TestFlagValue | 116 | null |
DisnakeDev/disnake | from datetime import datetime, timezone
import pytest
from disnake import Object
snowflake = 881536165478499999 # date/time of first commit
def test_created_at() -> None:
assert Object(snowflake).created_at == | datetime(2021, 8, 29, 13, 50, 0, tzinfo=timezone.utc) | assert | func_call | tests/test_object.py | test_created_at | 29 | null | |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import (
Guild,
Onboarding,
OnboardingPrompt,
OnboardingPromptOption,
OnboardingPromptType,
)
from disnake.types import onboarding as onboarding_types
onboarding_prompt_option_payload: onboarding_types.OnboardingPromptOption = {
"id": "0",
... | "test" | assert | string_literal | tests/test_onboarding.py | test_onboarding_prompt | TestOnboardingPrompt | 81 | null |
DisnakeDev/disnake | from typing_extensions import assert_type
from disnake.ext import commands
from tests.helpers import reveal_type
class TestDecorators:
def _test_typing_defaults(self) -> None:
base = commands.GroupMixin[None]()
# no cog
async def f1(ctx: CustomContext, a: int, b: str) -> bool: ...
... | CustomGroup) | assert_* | variable | tests/ext/commands/test_core.py | _test_typing_cls | TestDecorators | 68 | null |
DisnakeDev/disnake | from disnake.ext import commands
class TestParents:
def _create_cog(self):
class Cog(commands.Cog):
@commands.slash_command()
async def a(self, _) -> None: ...
@a.sub_command()
async def sub(self, _) -> None: ...
@a.sub_command_group()
... | None | assert | none_literal | tests/ext/commands/test_slash_core.py | test_parent | TestParents | 26 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | "asdf" | assert | string_literal | tests/ui/test_action_row.py | test_add_select | TestActionRow | 93 | null |
DisnakeDev/disnake | import datetime
from typing import Any
import pytest
from disnake.ext import commands
from disnake.ext.tasks import LF, Loop, loop
class TestLoops:
def test_factory(self) -> None:
with pytest.raises( | TypeError, match="must be callable") | pytest.raises | complex_expr | tests/ext/tasks/test_loops.py | test_factory | TestLoops | 69 | null |
DisnakeDev/disnake | import io
from datetime import datetime, timedelta
import pytest
from disnake import Color, Embed, File, embeds
from disnake.utils import MISSING, utcnow
_BASE = {"type": "rich"}
def embed() -> Embed:
time = utcnow() + timedelta(days=42)
return Embed(
type="link",
title="wow",
descri... | 20 | assert | numeric_literal | tests/test_embeds.py | test_len | 72 | null | |
DisnakeDev/disnake | from __future__ import annotations
import contextlib
from collections.abc import Iterator
from typing import Any, TypeVar
import pytest
from typing_extensions import assert_type
from disnake import ui
from disnake.ui.button import V_co
V = TypeVar("V", bound=ui.View)
I = TypeVar("I", bound=ui.Item)
def create_call... | ui.item.DecoratedItem[_CustomButton[ui.View]]) | assert_* | complex_expr | tests/ui/test_decorators.py | test_cls | TestDecorator | 62 | null |
DisnakeDev/disnake | from __future__ import annotations
import contextlib
from collections.abc import Iterator
from typing import Any, TypeVar
import pytest
from typing_extensions import assert_type
from disnake import ui
from disnake.ui.button import V_co
V = TypeVar("V", bound=ui.View)
I = TypeVar("I", bound=ui.Item)
def create_call... | ui.item.DecoratedItem[ui.Button[_CustomView]]) | assert_* | complex_expr | tests/ui/test_decorators.py | test_default | TestDecorator | 43 | null |
DisnakeDev/disnake | import warnings
import pytest
import disnake
from disnake import Permissions
from disnake.ext import commands
def meta(request) -> DecoratorMeta:
return DecoratorMeta(request.param)
def test_contexts_guildcommandinteraction(meta: DecoratorMeta) -> None:
class Cog(commands.Cog):
# this shouldn't rais... | disnake.InteractionContextTypes(guild=True) | assert | func_call | tests/ext/commands/test_base_core.py | test_contexts_guildcommandinteraction | 109 | null | |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | button2 | assert | variable | tests/ui/test_action_row.py | test_dunder | TestActionRow | 134 | null |
DisnakeDev/disnake | from __future__ import annotations
from typing import TYPE_CHECKING
from unittest import mock
import pytest
import disnake
from disnake import Interaction, InteractionResponseType as ResponseType # shortcut
from disnake.state import ConnectionState
from disnake.utils import MISSING
class TestInteractionResponse:
... | response._parent.token) | assert_* | complex_expr | tests/interactions/test_base.py | test_defer | TestInteractionResponse | 93 | null |
DisnakeDev/disnake | import warnings
import pytest
import disnake
from disnake import Permissions
from disnake.ext import commands
def meta(request) -> DecoratorMeta:
return DecoratorMeta(request.param)
class TestDefaultContexts:
def bot(self) -> commands.InteractionBot:
return commands.InteractionBot(
defa... | [1] | assert | collection | tests/ext/commands/test_base_core.py | test_default | TestDefaultContexts | 124 | null |
DisnakeDev/disnake | import pytest
import disnake
from disnake import message
from disnake.utils import MISSING
def _create_emoji(animated: bool) -> disnake.Emoji:
return disnake.Emoji(
guild=disnake.Object(1), # pyright: ignore[reportArgumentType]
state=MISSING,
data={"name": "test", "id": 1234, "animated": ... | expected | assert | variable | tests/test_message.py | test_convert_emoji_reaction__object | 57 | null | |
DisnakeDev/disnake | from unittest import mock
import pytest
import disnake
from disnake import ui
class TestDefaultValues:
@pytest.mark.parametrize(
("value_type", "expected"),
[
(disnake.Member, disnake.SelectDefaultValueType.user),
(disnake.ClientUser, disnake.SelectDefaultValueType.user),... | expected | assert | variable | tests/ui/test_select.py | test_mentionable | TestDefaultValues | 47 | null |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import AllowedMentions, Message, MessageType, Object
def test_from_message() -> None:
# as we don't have a message mock yet we are faking a message here with the necessary components
msg = mock.NonCallableMock()
msg.mention_everyone = True
users = ... | roles | assert | variable | tests/test_mentions.py | test_from_message | 101 | null | |
DisnakeDev/disnake | import datetime
from typing import Any
import pytest
from disnake.ext import commands
from disnake.ext.tasks import LF, Loop, loop
class TestLoops:
def test_mixing_time(self) -> None:
async def callback() -> None:
pass
with pytest.raises( | TypeError) | pytest.raises | variable | tests/ext/tasks/test_loops.py | test_mixing_time | TestLoops | 30 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | len(rows) | assert | func_call | tests/ui/test_action_row.py | test_rows_from_message | TestActionRow | 161 | null |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import AllowedMentions, Message, MessageType, Object
def test_from_message() -> None:
# as we don't have a message mock yet we are faking a message here with the necessary components
msg = mock.NonCallableMock()
msg.mention_everyone = True
users = ... | users | assert | variable | tests/test_mentions.py | test_from_message | 98 | null | |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import AllowedMentions, Message, MessageType, Object
@pytest.mark.parametrize(
("og", "to_merge", "expected"),
[
(AllowedMentions.none(), AllowedMentions.none(), AllowedMentions.none()),
(AllowedMentions.none(), AllowedMentions(), AllowedMe... | merged.roles | assert | complex_expr | tests/test_mentions.py | test_merge | 80 | null | |
DisnakeDev/disnake | import asyncio
import datetime
import functools
import inspect
import os
import sys
import warnings
from collections.abc import Callable
from dataclasses import dataclass
from datetime import timedelta, timezone
from typing import (
TYPE_CHECKING,
Annotated,
Any,
Literal,
Optional,
TypeVar,
... | None | assert | none_literal | tests/test_utils.py | test_parse_time | 75 | null | |
DisnakeDev/disnake | from disnake.ext import commands
class TestParents:
def _create_cog(self):
class Cog(commands.Cog):
@commands.slash_command()
async def a(self, _) -> None: ...
@a.sub_command()
async def sub(self, _) -> None: ...
@a.sub_command_group()
... | () | assert | collection | tests/ext/commands/test_slash_core.py | test_parents | TestParents | 47 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | exp_row | assert | variable | tests/ui/test_action_row.py | test_walk_components | TestActionRow | 203 | null |
DisnakeDev/disnake | from typing import Any
import pytest
import disnake
from disnake import Event
from disnake.ext import commands
def client() -> disnake.Client:
return disnake.Client()
def bot() -> commands.Bot:
return commands.Bot(
command_prefix=commands.when_mentioned,
command_sync_flags=commands.CommandSy... | 1 | assert | numeric_literal | tests/test_events.py | test_wait_for | 48 | null | |
DisnakeDev/disnake | import warnings
import pytest
import disnake
from disnake import Permissions
from disnake.ext import commands
def meta(request) -> DecoratorMeta:
return DecoratorMeta(request.param)
class TestDefaultContexts:
def bot(self) -> commands.InteractionBot:
return commands.InteractionBot(
defa... | [0] | assert | collection | tests/ext/commands/test_base_core.py | test_annotation_override | TestDefaultContexts | 138 | null |
DisnakeDev/disnake | import math
import pytest
from disnake import Color, Colour
def test_init() -> None:
with pytest.raises( | TypeError, match=r"Expected int parameter, received str instead.") | pytest.raises | complex_expr | tests/test_colour.py | test_init | 11 | null | |
DisnakeDev/disnake | from __future__ import annotations
from typing import TYPE_CHECKING
from unittest import mock
import pytest
import disnake
from disnake import Interaction, InteractionResponseType as ResponseType # shortcut
from disnake.state import ConnectionState
from disnake.utils import MISSING
class TestInteractionResponse:
... | TypeError, match="This interaction must be of type") | pytest.raises | complex_expr | tests/interactions/test_base.py | test_defer_invalid_parent | TestInteractionResponse | 127 | null |
DisnakeDev/disnake | from __future__ import annotations
from typing import TYPE_CHECKING
from unittest import mock
import pytest
import disnake
from disnake import Interaction, InteractionResponseType as ResponseType # shortcut
from disnake.state import ConnectionState
from disnake.utils import MISSING
class TestInteractionDataResolve... | 0 | assert | numeric_literal | tests/interactions/test_base.py | test_init_member | TestInteractionDataResolved | 169 | null |
DisnakeDev/disnake | import warnings
import pytest
import disnake
from disnake import Permissions
from disnake.ext import commands
def meta(request) -> DecoratorMeta:
return DecoratorMeta(request.param)
class TestDefaultPermissions:
def test_decorator_overwrite(self, meta: DecoratorMeta) -> None:
# putting the decorato... | ValueError, match="Cannot set `default_member_permissions`") | pytest.raises | complex_expr | tests/ext/commands/test_base_core.py | test_decorator_overwrite | TestDefaultPermissions | 48 | null |
DisnakeDev/disnake | import pytest
import disnake
from disnake import message
from disnake.utils import MISSING
@pytest.mark.parametrize(
"emoji",
[
# single char
"💯",
"🔥",
# with combining characters
"👩👩👧👦",
],
)
def test_convert_emoji_reaction__standard(emoji) -> None:
a... | emoji | assert | variable | tests/test_message.py | test_convert_emoji_reaction__standard | 21 | null | |
DisnakeDev/disnake | from typing import TYPE_CHECKING
import pytest
from disnake import activity as _activity
def activity() -> _activity.Activity:
return _activity.Activity()
def game() -> _activity.Game:
return _activity.Game(name="Celeste")
def custom_activity() -> _activity.CustomActivity:
return _activity.CustomActivi... | None | assert | none_literal | tests/test_activity.py | test_none | TestAssets | 45 | null |
DisnakeDev/disnake | from disnake.ext import commands
class TestParents:
def _create_cog(self):
class Cog(commands.Cog):
@commands.slash_command()
async def a(self, _) -> None: ...
@a.sub_command()
async def sub(self, _) -> None: ...
@a.sub_command_group()
... | cog.a | assert | complex_expr | tests/ext/commands/test_slash_core.py | test_parent | TestParents | 27 | null |
DisnakeDev/disnake | from datetime import datetime, timezone
import pytest
from disnake import Object
snowflake = 881536165478499999 # date/time of first commit
def test_compare() -> None:
assert Object(42) == Object(42)
assert Object(42) != | Object(43) | assert | func_call | tests/test_object.py | test_compare | 21 | null | |
DisnakeDev/disnake | import warnings
import pytest
import disnake
from disnake import Permissions
from disnake.ext import commands
def meta(request) -> DecoratorMeta:
return DecoratorMeta(request.param)
class TestDefaultContexts:
def bot(self) -> commands.InteractionBot:
return commands.InteractionBot(
defa... | c.body.to_dict() | assert | func_call | tests/ext/commands/test_base_core.py | test_default | TestDefaultContexts | 125 | null |
DisnakeDev/disnake | from typing import Literal
import pytest
from disnake.permissions import PermissionOverwrite, Permissions
class TestPermissionOverwrite:
def test_equality(self) -> None:
one = PermissionOverwrite()
two = PermissionOverwrite()
assert one is not | two | assert | variable | tests/test_permissions.py | test_equality | TestPermissionOverwrite | 218 | null |
DisnakeDev/disnake | import math
from typing import Any, Optional, Union
from unittest import mock
import pytest
import disnake
from disnake import Member, Role, User
from disnake.ext import commands
OptionType = disnake.OptionType
class TestBaseRange:
@pytest.mark.parametrize("empty", [None, ...])
def test_ellipsis(self, empt... | 1 | assert | numeric_literal | tests/ext/commands/test_params.py | test_ellipsis | TestBaseRange | 107 | null |
DisnakeDev/disnake | from typing import TYPE_CHECKING
import pytest
from disnake import activity as _activity
def activity() -> _activity.Activity:
return _activity.Activity()
def game() -> _activity.Game:
return _activity.Game(name="Celeste")
def custom_activity() -> _activity.CustomActivity:
return _activity.CustomActivi... | "hi" | assert | string_literal | tests/test_activity.py | test_text | TestAssets | 56 | null |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import AllowedMentions, Message, MessageType, Object
@pytest.mark.parametrize(
("am", "expected"),
[
(AllowedMentions(), {"parse": ["everyone", "users", "roles"], "replied_user": True}),
(AllowedMentions.all(), {"parse": ["everyone", "users... | am.to_dict() | assert | func_call | tests/test_mentions.py | test_to_dict | 52 | null | |
DisnakeDev/disnake | from __future__ import annotations
import contextlib
from collections.abc import Iterator
from typing import Any, TypeVar
import pytest
from typing_extensions import assert_type
from disnake import ui
from disnake.ui.button import V_co
V = TypeVar("V", bound=ui.View)
I = TypeVar("I", bound=ui.Item)
def create_call... | ui.StringSelect[Any] | assert | complex_expr | tests/ui/test_decorators.py | test_default | TestDecorator | 52 | null |
DisnakeDev/disnake | import math
from typing import Any, Optional, Union
from unittest import mock
import pytest
import disnake
from disnake import Member, Role, User
from disnake.ext import commands
OptionType = disnake.OptionType
class TestBaseRange:
@pytest.mark.parametrize("empty", [None, ...])
def test_ellipsis(self, empt... | None | assert | none_literal | tests/ext/commands/test_params.py | test_ellipsis | TestBaseRange | 108 | null |
DisnakeDev/disnake | from unittest import mock
import pytest
from disnake import AllowedMentions, Message, MessageType, Object
@pytest.mark.parametrize(
("og", "to_merge", "expected"),
[
(AllowedMentions.none(), AllowedMentions.none(), AllowedMentions.none()),
(AllowedMentions.none(), AllowedMentions(), AllowedMe... | merged.users | assert | complex_expr | tests/test_mentions.py | test_merge | 79 | null | |
DisnakeDev/disnake | from typing import TYPE_CHECKING
import pytest
from disnake import activity as _activity
def activity() -> _activity.Activity:
return _activity.Activity()
def game() -> _activity.Game:
return _activity.Game(name="Celeste")
def custom_activity() -> _activity.CustomActivity:
return _activity.CustomActivi... | "https://cdn.discordapp.com/app-assets/1010/1234.png" | assert | string_literal | tests/test_activity.py | test_asset_id_activity | TestAssets | 90 | null |
DisnakeDev/disnake | from disnake.ext import commands
class TestParents:
def _create_cog(self):
class Cog(commands.Cog):
@commands.slash_command()
async def a(self, _) -> None: ...
@a.sub_command()
async def sub(self, _) -> None: ...
@a.sub_command_group()
... | "a sub" | assert | string_literal | tests/ext/commands/test_slash_core.py | test_qualified_name | TestParents | 34 | null |
DisnakeDev/disnake | import pytest
import disnake
from disnake import message
from disnake.utils import MISSING
@pytest.mark.parametrize(
"emoji",
[
"test:1234",
":test:1234",
"<:test:1234>",
"a:test:1234",
"<a:test:1234>",
],
)
def test_convert_emoji_reaction__custom(emoji) -> None:
... | "test:1234" | assert | string_literal | tests/test_message.py | test_convert_emoji_reaction__custom | 35 | null | |
DisnakeDev/disnake | from typing import TYPE_CHECKING
from unittest import mock
import pytest
from typing_extensions import assert_type
import disnake
from disnake.ui import (
ActionRow,
Button,
Label,
Separator,
StringSelect,
TextInput,
WrappedComponent,
)
from disnake.ui._types import ActionRowMessageCompone... | expected | assert | variable | tests/ui/test_action_row.py | test_normalize_components__actionrow | 244 | null | |
DisnakeDev/disnake | from typing import Literal
import pytest
from disnake.permissions import PermissionOverwrite, Permissions
class TestPermissionOverwrite:
def test_update(self) -> None:
po = PermissionOverwrite()
assert po.manage_emojis is | None | assert | none_literal | tests/test_permissions.py | test_update | TestPermissionOverwrite | 306 | null |
DisnakeDev/disnake | import io
from datetime import datetime, timedelta
import pytest
from disnake import Color, Embed, File, embeds
from disnake.utils import MISSING, utcnow
_BASE = {"type": "rich"}
def embed() -> Embed:
time = utcnow() + timedelta(days=42)
return Embed(
type="link",
title="wow",
descri... | 69 | assert | numeric_literal | tests/test_embeds.py | test_len | 82 | null | |
DisnakeDev/disnake | from __future__ import annotations
import contextlib
from collections.abc import Iterator
from typing import Any, TypeVar
import pytest
from typing_extensions import assert_type
from disnake import ui
from disnake.ui.button import V_co
V = TypeVar("V", bound=ui.View)
I = TypeVar("I", bound=ui.Item)
def create_call... | {"custom_id": "123"} | assert | collection | tests/ui/test_decorators.py | test_default | TestDecorator | 46 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.