From 762861f3447698c6954016cf003758693dcc8bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:14:25 +0100 Subject: refactor: use is for None --- tests/test_account.py | 2 +- tests/test_bookmarks.py | 2 +- tests/test_hooks.py | 2 +- tests/test_media.py | 2 +- tests/test_notifications.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_account.py b/tests/test_account.py index 6f3b9a5..be48646 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -252,7 +252,7 @@ def test_featured_tags(api): assert featured_tag_list[0].name == "coolfree" assert "url" in featured_tag_list[0] finally: - if not featured_tag is None: + if featured_tag is not None: api.featured_tag_delete(featured_tag) api.featured_tag_delete(featured_tag_2) diff --git a/tests/test_bookmarks.py b/tests/test_bookmarks.py index e5e0d7c..2e1261b 100644 --- a/tests/test_bookmarks.py +++ b/tests/test_bookmarks.py @@ -21,6 +21,6 @@ def test_bookmarks(api, status): assert status_unbookmarked.bookmarked == False bookmarked_statuses_2 = api.bookmarks() - assert not bookmarked_statuses_2 is None + assert bookmarked_statuses_2 is not None assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1 diff --git a/tests/test_hooks.py b/tests/test_hooks.py index f0139e5..ab33d4c 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -32,7 +32,7 @@ def test_date_hook(status): @pytest.mark.vcr() def test_attribute_access(status): - assert status.id != None + assert status.id is not None with pytest.raises(AttributeError): status.id = 420 \ No newline at end of file diff --git a/tests/test_media.py b/tests/test_media.py index 7a358dd..9668f59 100644 --- a/tests/test_media.py +++ b/tests/test_media.py @@ -45,7 +45,7 @@ def test_media_post(api, sensitive): time.sleep(10) media2 = api.media(media) assert media2.id == media.id - assert not media2.url is None + assert media2.url is not None status = api.status_post( 'LOL check this out', diff --git a/tests/test_notifications.py b/tests/test_notifications.py index 6e761ce..858bad4 100644 --- a/tests/test_notifications.py +++ b/tests/test_notifications.py @@ -29,7 +29,7 @@ def test_notifications_dismiss_pre_2_9_2(api, api2): api.verify_minimum_version("2.9.2", cached=False) api.notifications_dismiss(notifications[0]) finally: - if not status is None: + if status is not None: api2.status_delete(status) @pytest.mark.vcr() -- cgit v1.2.3 From f04d57acbc5ef639c0dc70fde800cf5c24d0b967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:22:48 +0100 Subject: refactor: use is for True/False --- tests/test_bookmarks.py | 4 ++-- tests/test_constructor.py | 6 +++--- tests/test_filters.py | 14 +++++++------- tests/test_instance.py | 2 +- tests/test_media.py | 2 +- tests/test_push.py | 16 ++++++++-------- tests/test_streaming.py | 8 ++++---- tests/test_timeline.py | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/test_bookmarks.py b/tests/test_bookmarks.py index 2e1261b..54134e9 100644 --- a/tests/test_bookmarks.py +++ b/tests/test_bookmarks.py @@ -4,7 +4,7 @@ import pytest def test_bookmarks(api, status): status_bookmarked = api.status_bookmark(status) assert status_bookmarked - assert status_bookmarked.bookmarked == True + assert status_bookmarked.bookmarked bookmarked_statuses = api.bookmarks() assert bookmarked_statuses @@ -18,7 +18,7 @@ def test_bookmarks(api, status): status_unbookmarked = api.status_unbookmark(status_bookmarked) assert status_unbookmarked - assert status_unbookmarked.bookmarked == False + assert not status_unbookmarked.bookmarked bookmarked_statuses_2 = api.bookmarks() assert bookmarked_statuses_2 is not None diff --git a/tests/test_constructor.py b/tests/test_constructor.py index ebc9b85..d997a5d 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -33,9 +33,9 @@ def test_constructor_missing_client_secret(): @pytest.mark.vcr() def test_verify_version(api): - assert api.verify_minimum_version("2.3.3") == True - assert api.verify_minimum_version("9999.9999.9999") == False - assert api.verify_minimum_version("1.0.0") == True + assert api.verify_minimum_version("2.3.3") is True + assert api.verify_minimum_version("9999.9999.9999") is False + assert api.verify_minimum_version("1.0.0") is True def test_supported_version(api): assert Mastodon.get_supported_version() \ No newline at end of file diff --git a/tests/test_filters.py b/tests/test_filters.py index 3ffa726..d3dab8d 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -7,12 +7,12 @@ def test_filter_create(api): with vcr.use_cassette('test_filter_create.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'): keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None) try: - assert(keyword_filter) + assert keyword_filter all_filters = api.filters() - assert(keyword_filter in all_filters) - assert(keyword_filter.irreversible == False) - assert(keyword_filter.whole_word == True) + assert keyword_filter in all_filters + assert keyword_filter.irreversible is False + assert keyword_filter.whole_word is True keyword_filter_2 = api.filter(keyword_filter.id) assert(keyword_filter == keyword_filter_2) @@ -22,9 +22,9 @@ def test_filter_create(api): keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = False, expires_in = None) try: - assert(keyword_filter) - assert(keyword_filter.irreversible == False) - assert(keyword_filter.whole_word == False) + assert keyword_filter + assert keyword_filter.irreversible is False + assert keyword_filter.whole_word is False all_filters = api.filters() assert(keyword_filter in all_filters) diff --git a/tests/test_instance.py b/tests/test_instance.py index 8f3f142..1fbd692 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -38,7 +38,7 @@ def test_emoji(api): @pytest.mark.vcr() def test_health(api): - assert api.instance_health() == True + assert api.instance_health() is True @pytest.mark.vcr() def test_server_time(api): diff --git a/tests/test_media.py b/tests/test_media.py index 9668f59..e16fb4d 100644 --- a/tests/test_media.py +++ b/tests/test_media.py @@ -21,7 +21,7 @@ def test_media_post_v1(api): assert status try: - assert status['sensitive'] == False + assert status['sensitive'] is False assert status['media_attachments'] assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk" assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5 diff --git a/tests/test_push.py b/tests/test_push.py index daa99c7..b815910 100644 --- a/tests/test_push.py +++ b/tests/test_push.py @@ -57,14 +57,14 @@ def test_push_update(api): print(sub3) print(api.push_subscription()) - assert sub3.alerts.follow == False - assert sub3.alerts.favourite == False - assert sub3.alerts.reblog == False - assert sub3.alerts.mention == False - assert sub2.alerts.follow == True - assert sub2.alerts.favourite == True - assert sub2.alerts.reblog == True - assert sub2.alerts.mention == True + assert sub3.alerts.follow is False + assert sub3.alerts.favourite is False + assert sub3.alerts.reblog is False + assert sub3.alerts.mention is False + assert sub2.alerts.follow is True + assert sub2.alerts.favourite is True + assert sub2.alerts.reblog is True + assert sub2.alerts.mention is True @pytest.mark.vcr(match_on=['path']) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index fb60fe1..53a71ee 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -20,7 +20,7 @@ close_connections = False def patch_streaming(): global streaming_is_patched global close_connections - if streaming_is_patched == True: + if streaming_is_patched is True: return streaming_is_patched = True @@ -35,7 +35,7 @@ def patch_streaming(): response = real_connection_real_get_response(*args, **kwargs) real_body = b"" try: - while close_connections == False: + while close_connections is False: if len(select.select([response], [], [], 0.01)[0]) > 0: chunk = response.read(1) real_body += chunk @@ -165,7 +165,7 @@ def test_unknown_event(): 'data: {}', '', ]) - assert listener.bla_called == True + assert listener.bla_called is True assert listener.updates == [] assert listener.notifications == [] assert listener.deletes == [] @@ -195,7 +195,7 @@ def test_dotted_unknown_event(): 'data: {}', '', ]) - assert listener.do_something_called == True + assert listener.do_something_called is True assert listener.updates == [] assert listener.notifications == [] assert listener.deletes == [] diff --git a/tests/test_timeline.py b/tests/test_timeline.py index bc6728f..239fac3 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py @@ -60,8 +60,8 @@ def test_conversations(api, api2): assert conversations assert status.id in map(lambda x: x.last_status.id, conversations) assert account.id in map(lambda x: x.accounts[0].id, conversations) - assert conversations[0].unread == True - assert conversations2[0].unread == False + assert conversations[0].unread is True + assert conversations2[0].unread is False @pytest.mark.vcr() def test_min_max_id(api, status): -- cgit v1.2.3