Stabilize CI (#2575)

* attempt 'surely this one' on fixing test_idle and test_depr_warnings

* remove unused filterwarnings
This commit is contained in:
Harshil 2021-06-27 01:49:59 +05:30 committed by GitHub
parent ec3026673b
commit 9aec8deec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View file

@ -104,7 +104,6 @@ class TestAnimation:
assert message.animation.thumb.height == self.height
@flaky(3, 1)
@pytest.mark.filterwarnings("ignore:.*custom attributes")
def test_send_animation_custom_filename(self, bot, chat_id, animation_file, monkeypatch):
def make_assertion(url, data, **kwargs):
return data['animation'].filename == 'custom_filename'

View file

@ -717,7 +717,6 @@ class TestBot:
bot.send_chat_action(chat_id, 'unknown action')
# TODO: Needs improvement. We need incoming inline query to test answer.
@pytest.mark.filterwarnings("ignore:.*custom attributes")
def test_answer_inline_query(self, monkeypatch, bot):
# For now just test that our internals pass the correct data
def test(url, data, *args, **kwargs):
@ -970,7 +969,6 @@ class TestBot:
monkeypatch.delattr(bot, '_post')
# TODO: Needs improvement. No feasible way to test until bots can add members.
@pytest.mark.filterwarnings("ignore:.*custom attributes")
def test_kick_chat_member(self, monkeypatch, bot):
def test(url, data, *args, **kwargs):
chat_id = data['chat_id'] == 2

View file

@ -504,8 +504,13 @@ class TestUpdater:
updater.start_webhook(ip, port, clean=True, force_event_loop=False)
updater.stop()
for warning in recwarn.list:
print(warning.message)
for warning in recwarn:
print(warning)
try: # This is for flaky tests (there's an unclosed socket sometimes)
recwarn.pop(ResourceWarning) # internally iterates through recwarn.list and deletes it
except AssertionError:
pass
assert len(recwarn) == 3
assert str(recwarn[0].message).startswith('Old Handler API')
@ -523,6 +528,12 @@ class TestUpdater:
updater.stop()
for msg in recwarn:
print(msg)
try: # This is for flaky tests (there's an unclosed socket sometimes)
recwarn.pop(ResourceWarning) # internally iterates through recwarn.list and deletes it
except AssertionError:
pass
assert len(recwarn) == 2
assert str(recwarn[0].message).startswith('Old Handler API')
assert str(recwarn[1].message).startswith('The argument `clean` of')
@ -621,10 +632,17 @@ class TestUpdater:
# There is a chance of a conflict when getting updates since there can be many tests
# (bots) running simultaneously while testing in github actions.
for idx, log in enumerate(caplog.records):
if log.getMessage().startswith('Error while getting Updates: Conflict'):
records = caplog.records.copy() # To avoid iterating and removing at same time
for idx, log in enumerate(records):
print(log)
msg = log.getMessage()
if msg.startswith('Error while getting Updates: Conflict'):
caplog.records.pop(idx) # For stability
assert len(caplog.records) == 2, caplog.records
if msg.startswith('No error handlers are registered'):
caplog.records.pop(idx)
assert len(caplog.records) == 2, caplog.records
rec = caplog.records[-2]
assert rec.getMessage().startswith(f'Received signal {signal.SIGTERM}')