Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test Dependencies versions #2925

Merged
merged 32 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e01602f
update deps ver in requirements & pre-commit
harshil21 Mar 8, 2022
cc2bee7
file update from black
harshil21 Mar 8, 2022
6a316ec
files updated from mypy
harshil21 Mar 8, 2022
2b7e6f5
update pytest.approx usage
harshil21 Mar 8, 2022
f1622ca
update black target versions
harshil21 Mar 8, 2022
0fcb735
upgrade pylint to 2.13.7 and enable useless-suppression
harshil21 Apr 27, 2022
0c769ea
update black to 22.3.0 and update related files
harshil21 Apr 27, 2022
ab44f54
bump sphinx, furo and mypy dep
harshil21 Apr 27, 2022
013bc82
update files updated by mypy
harshil21 Apr 27, 2022
cc5afa9
add isort
harshil21 Apr 27, 2022
7aaa2e0
update a lot of files from isort
harshil21 Apr 27, 2022
e7e6243
bump pytest to v7.1.2
harshil21 Apr 27, 2022
9db149c
change import style project wide
harshil21 Apr 27, 2022
b9ee9bf
review
harshil21 Apr 28, 2022
b74abc9
update more examples from pylint
harshil21 Apr 28, 2022
11d2c92
bump pyupgrade, pytest-asyncio, and test checkout versions
harshil21 Apr 28, 2022
1aaab00
remove pytest.mark.asyncio decorator
harshil21 Apr 28, 2022
4cce9a2
use asyncio sleep in bot tests and reduce sleep duration in few tests
harshil21 Apr 28, 2022
afc23aa
revert lowering of sleep in poll tests
harshil21 Apr 28, 2022
c35caf1
try making deepsource happy
Bibo-Joshi Apr 29, 2022
fb394f1
merge branch v14 and fix conflicts
harshil21 Apr 30, 2022
0febf5a
remove pre-commit from CI since we added pre-commit.ci
harshil21 Apr 30, 2022
9ce2514
try fixing test on windows
harshil21 Apr 30, 2022
03f89fd
fix tests on windows 3.8+
harshil21 May 1, 2022
6cbe6ec
fix stuck test on windows
harshil21 May 1, 2022
4327522
add CI-config to pre-commit.yaml
Bibo-Joshi May 2, 2022
622991e
Use call_after some more
Bibo-Joshi May 2, 2022
b7f195f
remove globally unused pylint ignores
Bibo-Joshi May 3, 2022
ee2b10c
Bump pylint again
Bibo-Joshi May 3, 2022
267c5d8
Merge branch 'v14' into upgrade-test-dep-ver
Bibo-Joshi May 3, 2022
0f63d4a
merge v14 and fix conflicts
harshil21 May 3, 2022
16b62d9
fix pre-commit
harshil21 May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import datetime
import asyncio
import inspect
import logging
Expand Down Expand Up @@ -2138,7 +2137,7 @@ async def test_advanced_chat_invite_links(self, bot, channel_id, datetime):
)
assert invite_link.invite_link != ''
assert not invite_link.invite_link.endswith('...')
assert pytest.approx(invite_link.expire_date == aware_time_in_future)
assert invite_link.expire_date - aware_time_in_future < dtm.timedelta(seconds=1)
assert invite_link.member_limit == 10

add_seconds = dtm.timedelta(0, 80)
Expand All @@ -2154,7 +2153,7 @@ async def test_advanced_chat_invite_links(self, bot, channel_id, datetime):
name='NewName',
)
assert edited_invite_link.invite_link == invite_link.invite_link
assert pytest.approx(edited_invite_link.expire_date == aware_time_in_future)
assert edited_invite_link.expire_date - aware_time_in_future < dtm.timedelta(seconds=1)
assert edited_invite_link.name == 'NewName'
assert edited_invite_link.member_limit == 20

Expand All @@ -2165,16 +2164,16 @@ async def test_advanced_chat_invite_links(self, bot, channel_id, datetime):
creates_join_request=True,
)
assert edited_invite_link.invite_link == invite_link.invite_link
assert pytest.approx(edited_invite_link.expire_date == aware_time_in_future)
assert not edited_invite_link.expire_date
assert edited_invite_link.name == 'EvenNewerName'
assert edited_invite_link.creates_join_request is True
assert edited_invite_link.creates_join_request
assert edited_invite_link.member_limit is None

revoked_invite_link = await bot.revoke_chat_invite_link(
channel_id, invite_link.invite_link
)
assert revoked_invite_link.invite_link == invite_link.invite_link
assert revoked_invite_link.is_revoked is True
assert revoked_invite_link.is_revoked

@flaky(3, 1)
@pytest.mark.asyncio
Expand All @@ -2189,7 +2188,7 @@ async def test_advanced_chat_invite_links_default_tzinfo(self, tz_bot, channel_i
)
assert invite_link.invite_link != ''
assert not invite_link.invite_link.endswith('...')
assert pytest.approx(invite_link.expire_date == aware_expire_date)
assert invite_link.expire_date - aware_expire_date < dtm.timedelta(seconds=1)
assert invite_link.member_limit == 10

add_seconds = dtm.timedelta(0, 80)
Expand All @@ -2204,7 +2203,7 @@ async def test_advanced_chat_invite_links_default_tzinfo(self, tz_bot, channel_i
name='NewName',
)
assert edited_invite_link.invite_link == invite_link.invite_link
assert pytest.approx(edited_invite_link.expire_date == aware_expire_date)
assert edited_invite_link.expire_date - aware_expire_date < dtm.timedelta(seconds=1)
assert edited_invite_link.name == 'NewName'
assert edited_invite_link.member_limit == 20

Expand All @@ -2215,16 +2214,16 @@ async def test_advanced_chat_invite_links_default_tzinfo(self, tz_bot, channel_i
creates_join_request=True,
)
assert edited_invite_link.invite_link == invite_link.invite_link
assert pytest.approx(edited_invite_link.expire_date == aware_expire_date)
assert not edited_invite_link.expire_date
assert edited_invite_link.name == 'EvenNewerName'
assert edited_invite_link.creates_join_request is True
assert edited_invite_link.creates_join_request
assert edited_invite_link.member_limit is None

revoked_invite_link = await tz_bot.revoke_chat_invite_link(
channel_id, invite_link.invite_link
)
assert revoked_invite_link.invite_link == invite_link.invite_link
assert revoked_invite_link.is_revoked is True
assert revoked_invite_link.is_revoked

@flaky(3, 1)
@pytest.mark.asyncio
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chatinvitelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestChatInviteLink:
creates_join_request = (False,)
primary = True
revoked = False
expire_date = datetime.datetime.utcnow()
expire_date = datetime.datetime.now(datetime.timezone.utc)
member_limit = 42
name = 'LinkName'
pending_join_request_count = 42
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_de_json_all_args(self, bot, creator):
assert invite_link.creates_join_request == self.creates_join_request
assert invite_link.is_primary == self.primary
assert invite_link.is_revoked == self.revoked
assert pytest.approx(invite_link.expire_date == self.expire_date)
assert invite_link.expire_date - self.expire_date < datetime.timedelta(seconds=1)
assert to_timestamp(invite_link.expire_date) == to_timestamp(self.expire_date)
assert invite_link.member_limit == self.member_limit
assert invite_link.name == self.name
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chatjoinrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ def test_de_json(self, bot, time):

assert chat_join_request.chat == self.chat
assert chat_join_request.from_user == self.from_user
assert pytest.approx(chat_join_request.date == time)
assert chat_join_request.date - time < datetime.timedelta(seconds=1)
assert to_timestamp(chat_join_request.date) == to_timestamp(time)

json_dict.update({'bio': self.bio, 'invite_link': self.invite_link.to_dict()})
chat_join_request = ChatJoinRequest.de_json(json_dict, bot)

assert chat_join_request.chat == self.chat
assert chat_join_request.from_user == self.from_user
assert pytest.approx(chat_join_request.date == time)
assert chat_join_request.date - time < datetime.timedelta(seconds=1)
assert to_timestamp(chat_join_request.date) == to_timestamp(time)
assert chat_join_request.bio == self.bio
assert chat_join_request.invite_link == self.invite_link
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chatmemberupdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_de_json_required_args(self, bot, user, chat, old_chat_member, new_chat_

assert chat_member_updated.chat == chat
assert chat_member_updated.from_user == user
assert pytest.approx(chat_member_updated.date == time)
assert chat_member_updated.date - time < datetime.timedelta(seconds=1)
assert to_timestamp(chat_member_updated.date) == to_timestamp(time)
assert chat_member_updated.old_chat_member == old_chat_member
assert chat_member_updated.new_chat_member == new_chat_member
Expand All @@ -127,7 +127,7 @@ def test_de_json_all_args(

assert chat_member_updated.chat == chat
assert chat_member_updated.from_user == user
assert pytest.approx(chat_member_updated.date == time)
assert chat_member_updated.date - time < datetime.timedelta(seconds=1)
harshil21 marked this conversation as resolved.
Show resolved Hide resolved
assert to_timestamp(chat_member_updated.date) == to_timestamp(time)
assert chat_member_updated.old_chat_member == old_chat_member
assert chat_member_updated.new_chat_member == new_chat_member
Expand Down
8 changes: 4 additions & 4 deletions tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ async def test_send_live_location(self, bot, chat_id):
protect_content=True,
)
assert message.location
assert pytest.approx(52.223880, message.location.latitude)
assert pytest.approx(5.166146, message.location.longitude)
assert 52.223880 == pytest.approx(message.location.latitude, rel=1e-5)
assert 5.166146 == pytest.approx(message.location.longitude, rel=1e-5)
assert message.location.live_period == 80
assert message.location.horizontal_accuracy == 50
assert message.location.heading == 90
Expand All @@ -100,8 +100,8 @@ async def test_send_live_location(self, bot, chat_id):
proximity_alert_radius=500,
)

assert pytest.approx(52.223098, message2.location.latitude)
assert pytest.approx(5.164306, message2.location.longitude)
assert 52.223098 == pytest.approx(message2.location.latitude, rel=1e-5)
assert 5.164306 == pytest.approx(message2.location.longitude, rel=1e-5)
assert message2.location.horizontal_accuracy == 30
assert message2.location.heading == 10
assert message2.location.proximity_alert_radius == 500
Expand Down
6 changes: 3 additions & 3 deletions tests/test_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
import pytest

from datetime import datetime
from datetime import datetime, timedelta, timezone


from telegram import Poll, PollOption, PollAnswer, User, MessageEntity
Expand Down Expand Up @@ -157,7 +157,7 @@ class TestPoll:
).decode('unicode-escape')
explanation_entities = [MessageEntity(13, 17, MessageEntity.URL)]
open_period = 42
close_date = datetime.utcnow()
close_date = datetime.now(timezone.utc)

def test_de_json(self, bot):
json_dict = {
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_de_json(self, bot):
assert poll.explanation == self.explanation
assert poll.explanation_entities == self.explanation_entities
assert poll.open_period == self.open_period
assert pytest.approx(poll.close_date == self.close_date)
assert poll.close_date - self.close_date < timedelta(seconds=1)
assert to_timestamp(poll.close_date) == to_timestamp(self.close_date)

def test_to_dict(self, poll):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_voicechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_equality(self, user1, user2):


class TestVoiceChatScheduled:
start_date = dtm.datetime.utcnow()
start_date = dtm.datetime.now(dtm.timezone.utc)

def test_slot_behaviour(self, mro_slots):
inst = VoiceChatScheduled(self.start_date)
Expand All @@ -156,15 +156,15 @@ def test_slot_behaviour(self, mro_slots):
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"

def test_expected_values(self):
assert pytest.approx(VoiceChatScheduled(start_date=self.start_date) == self.start_date)
assert VoiceChatScheduled(self.start_date).start_date == self.start_date

def test_de_json(self, bot):
assert VoiceChatScheduled.de_json({}, bot=bot) is None

json_dict = {'start_date': to_timestamp(self.start_date)}
voice_chat_scheduled = VoiceChatScheduled.de_json(json_dict, bot)

assert pytest.approx(voice_chat_scheduled.start_date == self.start_date)
assert voice_chat_scheduled.start_date - self.start_date < dtm.timedelta(seconds=1)

def test_to_dict(self):
voice_chat_scheduled = VoiceChatScheduled(self.start_date)
Expand Down