Closed
Description
Checklist
- I am sure the error is coming from aiogram code
- I have searched in the issue tracker for similar bug reports, including closed ones
Operating system
Ubuntu 20.04, Windows 8
Python version
3.10
aiogram version
3.0b4
Expected behavior
I expect to have these CommandObject instances to be equal
CommandObject(command='start')
- Message with text='/start', passed through Command filter.
Current behavior
I did some tests.
Expected :{'command': CommandObject(prefix='/', command='start', mention=None)}
Actual :{'command': CommandObject(prefix='/', command='start', mention='')}
Steps to reproduce
- Create a handler with Command filter.
- Catch a message with simple '/example' command
- Check CommandObject instance, mention will not be None, it's empty string.
Code example
import datetime
import pytest
from aiogram.filters import Command, CommandObject
from aiogram.types import Chat, Message
from tests.mocked_bot import MockedBot # aiogram/tests/mocked_bot.py
@pytest.mark.parametrize('schema', ['start'])
@pytest.mark.parametrize('input_command', ['/start'])
@pytest.mark.asyncio
async def test_mention_error(schema: str, input_command: str):
command = Command(commands=schema)
response = await command.__call__(
Message(
message_id=1,
chat=Chat(
id=1,
type="private",
),
text=input_command,
date=datetime.datetime.now(),
),
MockedBot(),
)
assert response == {'command': CommandObject(command='start')}
Logs
============================= test session starts =============================
collecting ... collected 1 item
test_usage.py::test_mention_error[/start-start] FAILED [100%]
test_usage.py:9 (test_mention_error[/start-start])
{'command': CommandObject(prefix='/', command='start', mention='')} != {'command': CommandObject(prefix='/', command='start', mention=None)}
Expected :{'command': CommandObject(prefix='/', command='start', mention=None)}
Actual :{'command': CommandObject(prefix='/', command='start', mention='')}
> assert response == {'command': CommandObject(command='start')}
E AssertionError: assert {'command': CommandObject(prefix='/', command='start', mention='')} == {'command': CommandObject(prefix='/', command='start', mention=None)}
E Differing items:
E {'command': CommandObject(prefix='/', command='start', mention='')} != {'command': CommandObject(prefix='/', command='start', mention=None)}
E Full diff:
E - {'command': CommandObject(prefix='/', command='start', mention=None)}
E ? ^^^^
E + {'command': CommandObject(prefix='/', command='start', mention='')}
E ? ^^
Additional information
I know it's not important, None and empty string casts to False, but anyway.