Remove assert statement from non-test files

This commit is contained in:
deepsource-autofix[bot] 2020-11-08 21:48:49 +00:00 committed by GitHub
parent 44cd1fd974
commit dd50a9b13e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 637 additions and 323 deletions

View file

@ -21,7 +21,8 @@ def data():
def test_generate_hash(data):
res = generate_hash(data, TOKEN)
assert res == data['hash']
if res != data['hash']:
raise AssertionError
class Test_check_token:
@ -29,18 +30,22 @@ class Test_check_token:
This case gonna be deleted
"""
def test_ok(self, data):
assert check_token(data, TOKEN) is True
if check_token(data, TOKEN) is not True:
raise AssertionError
def test_fail(self, data):
data.pop('username')
assert check_token(data, TOKEN) is False
if check_token(data, TOKEN) is not False:
raise AssertionError
class Test_check_integrity:
def test_ok(self, data):
assert check_integrity(TOKEN, data) is True
if check_integrity(TOKEN, data) is not True:
raise AssertionError
def test_fail(self, data):
data.pop('username')
assert check_integrity(TOKEN, data) is False
if check_integrity(TOKEN, data) is not False:
raise AssertionError

View file

@ -48,7 +48,8 @@ def get_bot_user_fixture(monkeypatch):
class TestDeepLinking:
async def test_get_start_link(self, payload):
link = await get_start_link(payload)
assert link == f'https://t.me/{dataset.USER["username"]}?start={payload}'
if link != f'https://t.me/{dataset.USER["username"]}?start={payload}':
raise AssertionError
async def test_wrong_symbols(self, wrong_payload):
with pytest.raises(ValueError):
@ -56,13 +57,15 @@ class TestDeepLinking:
async def test_get_startgroup_link(self, payload):
link = await get_startgroup_link(payload)
assert link == f'https://t.me/{dataset.USER["username"]}?startgroup={payload}'
if link != f'https://t.me/{dataset.USER["username"]}?startgroup={payload}':
raise AssertionError
async def test_filter_encode_and_decode(self, payload):
_payload = filter_payload(payload)
encoded = encode_payload(_payload)
decoded = decode_payload(encoded)
assert decoded == str(payload)
if decoded != str(payload):
raise AssertionError
async def test_get_start_link_with_encoding(self, payload):
# define link
@ -72,4 +75,5 @@ class TestDeepLinking:
payload = filter_payload(payload)
encoded_payload = encode_payload(payload)
assert link == f'https://t.me/{dataset.USER["username"]}?start={encoded_payload}'
if link != f'https://t.me/{dataset.USER["username"]}?start={encoded_payload}':
raise AssertionError

View file

@ -4,11 +4,13 @@ from aiogram.utils.deprecated import DeprecatedReadOnlyClassVar
def test_DeprecatedReadOnlyClassVarCD():
assert DeprecatedReadOnlyClassVar.__slots__ == ("_new_value_getter", "_warning_message")
if DeprecatedReadOnlyClassVar.__slots__ != ("_new_value_getter", "_warning_message"):
raise AssertionError
new_value_of_deprecated_cls_cd = "mpa"
deprecated_cd = DeprecatedReadOnlyClassVar("mopekaa", lambda owner: new_value_of_deprecated_cls_cd)
with pytest.warns(DeprecationWarning):
pseudo_owner_cls = type("OpekaCla$$", (), {})
assert deprecated_cd.__get__(None, pseudo_owner_cls) == new_value_of_deprecated_cls_cd
if deprecated_cd.__get__(None, pseudo_owner_cls) != new_value_of_deprecated_cls_cd:
raise AssertionError

View file

@ -10,7 +10,8 @@ class TestOrderedHelper:
C = Item()
B = Item()
assert Helper.all() == ['A', 'D', 'C', 'B']
if Helper.all() != ['A', 'D', 'C', 'B']:
raise AssertionError
def test_list_items_are_ordered(self):
class Helper(OrderedHelper):
@ -19,4 +20,5 @@ class TestOrderedHelper:
C = ListItem()
B = ListItem()
assert Helper.all() == ['A', 'D', 'C', 'B']
if Helper.all() != ['A', 'D', 'C', 'B']:
raise AssertionError

View file

@ -5,7 +5,9 @@ from aiogram.utils import markdown
class TestMarkdownEscape:
def test_equality_sign_is_escaped(self):
assert markdown.escape_md(r"e = mc2") == r"e \= mc2"
if markdown.escape_md(r"e = mc2") != r"e \= mc2":
raise AssertionError
def test_pre_escaped(self):
assert markdown.escape_md(r"hello\.") == r"hello\\\."
if markdown.escape_md(r"hello\.") != r"hello\\\.":
raise AssertionError

View file

@ -4,22 +4,24 @@ from aiogram.utils import text_decorations
class TestTextDecorations:
def test_unparse_entities_normal_text(self):
assert text_decorations.markdown_decoration.unparse(
if text_decorations.markdown_decoration.unparse(
"hi i'm bold and italic and still bold",
entities=[
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
]
) == "hi *i'm bold _\rand italic_\r and still bold*"
) != "hi *i'm bold _\rand italic_\r and still bold*":
raise AssertionError
def test_unparse_entities_emoji_text(self):
"""
emoji is encoded as two chars in json
"""
assert text_decorations.markdown_decoration.unparse(
if text_decorations.markdown_decoration.unparse(
"🚀 i'm bold and italic and still bold",
entities=[
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
]
) == "🚀 *i'm bold _\rand italic_\r and still bold*"
) != "🚀 *i'm bold _\rand italic_\r and still bold*":
raise AssertionError