diff options
author | Lorenz Diener <[email protected]> | 2022-11-21 20:17:18 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-21 20:17:18 +0200 |
commit | 943782afc394f52377223fb6b777946d5b2148ff (patch) | |
tree | 7fd8ad2031c281ac2a7cbc297fb20edd2fa4152e /tests | |
parent | 98760f650bcaafedead3f0b6e2b0c594ab857338 (diff) | |
parent | f04d57acbc5ef639c0dc70fde800cf5c24d0b967 (diff) | |
download | mastodon.py-943782afc394f52377223fb6b777946d5b2148ff.tar.gz |
Merge pull request #269 from eumiro/none_identity
Refactor: use is for None/True/False
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_account.py | 2 | ||||
-rw-r--r-- | tests/test_bookmarks.py | 6 | ||||
-rw-r--r-- | tests/test_constructor.py | 6 | ||||
-rw-r--r-- | tests/test_filters.py | 14 | ||||
-rw-r--r-- | tests/test_hooks.py | 2 | ||||
-rw-r--r-- | tests/test_instance.py | 2 | ||||
-rw-r--r-- | tests/test_media.py | 4 | ||||
-rw-r--r-- | tests/test_notifications.py | 2 | ||||
-rw-r--r-- | tests/test_push.py | 16 | ||||
-rw-r--r-- | tests/test_streaming.py | 8 | ||||
-rw-r--r-- | tests/test_timeline.py | 4 |
11 files changed, 33 insertions, 33 deletions
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): | |||
252 | assert featured_tag_list[0].name == "coolfree" | 252 | assert featured_tag_list[0].name == "coolfree" |
253 | assert "url" in featured_tag_list[0] | 253 | assert "url" in featured_tag_list[0] |
254 | finally: | 254 | finally: |
255 | if not featured_tag is None: | 255 | if featured_tag is not None: |
256 | api.featured_tag_delete(featured_tag) | 256 | api.featured_tag_delete(featured_tag) |
257 | api.featured_tag_delete(featured_tag_2) | 257 | api.featured_tag_delete(featured_tag_2) |
258 | 258 | ||
diff --git a/tests/test_bookmarks.py b/tests/test_bookmarks.py index e5e0d7c..54134e9 100644 --- a/tests/test_bookmarks.py +++ b/tests/test_bookmarks.py | |||
@@ -4,7 +4,7 @@ import pytest | |||
4 | def test_bookmarks(api, status): | 4 | def test_bookmarks(api, status): |
5 | status_bookmarked = api.status_bookmark(status) | 5 | status_bookmarked = api.status_bookmark(status) |
6 | assert status_bookmarked | 6 | assert status_bookmarked |
7 | assert status_bookmarked.bookmarked == True | 7 | assert status_bookmarked.bookmarked |
8 | 8 | ||
9 | bookmarked_statuses = api.bookmarks() | 9 | bookmarked_statuses = api.bookmarks() |
10 | assert bookmarked_statuses | 10 | assert bookmarked_statuses |
@@ -18,9 +18,9 @@ def test_bookmarks(api, status): | |||
18 | 18 | ||
19 | status_unbookmarked = api.status_unbookmark(status_bookmarked) | 19 | status_unbookmarked = api.status_unbookmark(status_bookmarked) |
20 | assert status_unbookmarked | 20 | assert status_unbookmarked |
21 | assert status_unbookmarked.bookmarked == False | 21 | assert not status_unbookmarked.bookmarked |
22 | 22 | ||
23 | bookmarked_statuses_2 = api.bookmarks() | 23 | bookmarked_statuses_2 = api.bookmarks() |
24 | assert not bookmarked_statuses_2 is None | 24 | assert bookmarked_statuses_2 is not None |
25 | assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1 | 25 | assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1 |
26 | 26 | ||
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(): | |||
33 | 33 | ||
34 | @pytest.mark.vcr() | 34 | @pytest.mark.vcr() |
35 | def test_verify_version(api): | 35 | def test_verify_version(api): |
36 | assert api.verify_minimum_version("2.3.3") == True | 36 | assert api.verify_minimum_version("2.3.3") is True |
37 | assert api.verify_minimum_version("9999.9999.9999") == False | 37 | assert api.verify_minimum_version("9999.9999.9999") is False |
38 | assert api.verify_minimum_version("1.0.0") == True | 38 | assert api.verify_minimum_version("1.0.0") is True |
39 | 39 | ||
40 | def test_supported_version(api): | 40 | def test_supported_version(api): |
41 | assert Mastodon.get_supported_version() \ No newline at end of file | 41 | 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): | |||
7 | with vcr.use_cassette('test_filter_create.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'): | 7 | with vcr.use_cassette('test_filter_create.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'): |
8 | keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None) | 8 | keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None) |
9 | try: | 9 | try: |
10 | assert(keyword_filter) | 10 | assert keyword_filter |
11 | 11 | ||
12 | all_filters = api.filters() | 12 | all_filters = api.filters() |
13 | assert(keyword_filter in all_filters) | 13 | assert keyword_filter in all_filters |
14 | assert(keyword_filter.irreversible == False) | 14 | assert keyword_filter.irreversible is False |
15 | assert(keyword_filter.whole_word == True) | 15 | assert keyword_filter.whole_word is True |
16 | 16 | ||
17 | keyword_filter_2 = api.filter(keyword_filter.id) | 17 | keyword_filter_2 = api.filter(keyword_filter.id) |
18 | assert(keyword_filter == keyword_filter_2) | 18 | assert(keyword_filter == keyword_filter_2) |
@@ -22,9 +22,9 @@ def test_filter_create(api): | |||
22 | 22 | ||
23 | keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = False, expires_in = None) | 23 | keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = False, expires_in = None) |
24 | try: | 24 | try: |
25 | assert(keyword_filter) | 25 | assert keyword_filter |
26 | assert(keyword_filter.irreversible == False) | 26 | assert keyword_filter.irreversible is False |
27 | assert(keyword_filter.whole_word == False) | 27 | assert keyword_filter.whole_word is False |
28 | 28 | ||
29 | all_filters = api.filters() | 29 | all_filters = api.filters() |
30 | assert(keyword_filter in all_filters) | 30 | assert(keyword_filter in all_filters) |
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): | |||
32 | 32 | ||
33 | @pytest.mark.vcr() | 33 | @pytest.mark.vcr() |
34 | def test_attribute_access(status): | 34 | def test_attribute_access(status): |
35 | assert status.id != None | 35 | assert status.id is not None |
36 | with pytest.raises(AttributeError): | 36 | with pytest.raises(AttributeError): |
37 | status.id = 420 | 37 | status.id = 420 |
38 | \ No newline at end of file | 38 | \ No newline at end of file |
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): | |||
38 | 38 | ||
39 | @pytest.mark.vcr() | 39 | @pytest.mark.vcr() |
40 | def test_health(api): | 40 | def test_health(api): |
41 | assert api.instance_health() == True | 41 | assert api.instance_health() is True |
42 | 42 | ||
43 | @pytest.mark.vcr() | 43 | @pytest.mark.vcr() |
44 | def test_server_time(api): | 44 | def test_server_time(api): |
diff --git a/tests/test_media.py b/tests/test_media.py index 7a358dd..e16fb4d 100644 --- a/tests/test_media.py +++ b/tests/test_media.py | |||
@@ -21,7 +21,7 @@ def test_media_post_v1(api): | |||
21 | assert status | 21 | assert status |
22 | 22 | ||
23 | try: | 23 | try: |
24 | assert status['sensitive'] == False | 24 | assert status['sensitive'] is False |
25 | assert status['media_attachments'] | 25 | assert status['media_attachments'] |
26 | assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk" | 26 | assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk" |
27 | assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5 | 27 | assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5 |
@@ -45,7 +45,7 @@ def test_media_post(api, sensitive): | |||
45 | time.sleep(10) | 45 | time.sleep(10) |
46 | media2 = api.media(media) | 46 | media2 = api.media(media) |
47 | assert media2.id == media.id | 47 | assert media2.id == media.id |
48 | assert not media2.url is None | 48 | assert media2.url is not None |
49 | 49 | ||
50 | status = api.status_post( | 50 | status = api.status_post( |
51 | 'LOL check this out', | 51 | '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): | |||
29 | api.verify_minimum_version("2.9.2", cached=False) | 29 | api.verify_minimum_version("2.9.2", cached=False) |
30 | api.notifications_dismiss(notifications[0]) | 30 | api.notifications_dismiss(notifications[0]) |
31 | finally: | 31 | finally: |
32 | if not status is None: | 32 | if status is not None: |
33 | api2.status_delete(status) | 33 | api2.status_delete(status) |
34 | 34 | ||
35 | @pytest.mark.vcr() | 35 | @pytest.mark.vcr() |
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): | |||
57 | print(sub3) | 57 | print(sub3) |
58 | print(api.push_subscription()) | 58 | print(api.push_subscription()) |
59 | 59 | ||
60 | assert sub3.alerts.follow == False | 60 | assert sub3.alerts.follow is False |
61 | assert sub3.alerts.favourite == False | 61 | assert sub3.alerts.favourite is False |
62 | assert sub3.alerts.reblog == False | 62 | assert sub3.alerts.reblog is False |
63 | assert sub3.alerts.mention == False | 63 | assert sub3.alerts.mention is False |
64 | assert sub2.alerts.follow == True | 64 | assert sub2.alerts.follow is True |
65 | assert sub2.alerts.favourite == True | 65 | assert sub2.alerts.favourite is True |
66 | assert sub2.alerts.reblog == True | 66 | assert sub2.alerts.reblog is True |
67 | assert sub2.alerts.mention == True | 67 | assert sub2.alerts.mention is True |
68 | 68 | ||
69 | 69 | ||
70 | @pytest.mark.vcr(match_on=['path']) | 70 | @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 | |||
20 | def patch_streaming(): | 20 | def patch_streaming(): |
21 | global streaming_is_patched | 21 | global streaming_is_patched |
22 | global close_connections | 22 | global close_connections |
23 | if streaming_is_patched == True: | 23 | if streaming_is_patched is True: |
24 | return | 24 | return |
25 | streaming_is_patched = True | 25 | streaming_is_patched = True |
26 | 26 | ||
@@ -35,7 +35,7 @@ def patch_streaming(): | |||
35 | response = real_connection_real_get_response(*args, **kwargs) | 35 | response = real_connection_real_get_response(*args, **kwargs) |
36 | real_body = b"" | 36 | real_body = b"" |
37 | try: | 37 | try: |
38 | while close_connections == False: | 38 | while close_connections is False: |
39 | if len(select.select([response], [], [], 0.01)[0]) > 0: | 39 | if len(select.select([response], [], [], 0.01)[0]) > 0: |
40 | chunk = response.read(1) | 40 | chunk = response.read(1) |
41 | real_body += chunk | 41 | real_body += chunk |
@@ -165,7 +165,7 @@ def test_unknown_event(): | |||
165 | 'data: {}', | 165 | 'data: {}', |
166 | '', | 166 | '', |
167 | ]) | 167 | ]) |
168 | assert listener.bla_called == True | 168 | assert listener.bla_called is True |
169 | assert listener.updates == [] | 169 | assert listener.updates == [] |
170 | assert listener.notifications == [] | 170 | assert listener.notifications == [] |
171 | assert listener.deletes == [] | 171 | assert listener.deletes == [] |
@@ -195,7 +195,7 @@ def test_dotted_unknown_event(): | |||
195 | 'data: {}', | 195 | 'data: {}', |
196 | '', | 196 | '', |
197 | ]) | 197 | ]) |
198 | assert listener.do_something_called == True | 198 | assert listener.do_something_called is True |
199 | assert listener.updates == [] | 199 | assert listener.updates == [] |
200 | assert listener.notifications == [] | 200 | assert listener.notifications == [] |
201 | assert listener.deletes == [] | 201 | 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): | |||
60 | assert conversations | 60 | assert conversations |
61 | assert status.id in map(lambda x: x.last_status.id, conversations) | 61 | assert status.id in map(lambda x: x.last_status.id, conversations) |
62 | assert account.id in map(lambda x: x.accounts[0].id, conversations) | 62 | assert account.id in map(lambda x: x.accounts[0].id, conversations) |
63 | assert conversations[0].unread == True | 63 | assert conversations[0].unread is True |
64 | assert conversations2[0].unread == False | 64 | assert conversations2[0].unread is False |
65 | 65 | ||
66 | @pytest.mark.vcr() | 66 | @pytest.mark.vcr() |
67 | def test_min_max_id(api, status): | 67 | def test_min_max_id(api, status): |