From 325cc917d5ad14b130b156d23b7adca46499dc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Fri, 2 Dec 2022 22:04:23 +0100 Subject: refactor: use f-strings --- tests/test_create_app.py | 2 +- tests/test_pagination.py | 15 ++++++++++----- tests/test_status.py | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/test_create_app.py b/tests/test_create_app.py index c7282df..97556c6 100644 --- a/tests/test_create_app.py +++ b/tests/test_create_app.py @@ -64,7 +64,7 @@ def test_app_account_create(): test_app[1], api_base_url="http://localhost:3000/" ) - test_token = test_app_api.create_account("coolguy" + suffix, "swordfish", "email@localhost" + suffix, agreement=True) + test_token = test_app_api.create_account(f"coolguy{suffix}", "swordfish", f"email@localhost{suffix}", agreement=True) assert test_token # We can also test resending (marginally) diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 9f26140..0c83fe4 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -16,7 +16,7 @@ UNLIKELY_HASHTAG = "fgiztsshwiaqqiztpmmjbtvmescsculuvmgjgopwoeidbcrixp" def many_statuses(api, n=10, suffix=''): statuses = list() for i in range(n): - status = api.status_post("Toot number {}!{}".format(i, suffix)) + status = api.status_post(f"Toot number {i}!{suffix}") statuses.append(status) yield statuses for status in statuses: @@ -102,10 +102,15 @@ def test_link_headers(api): _id='abc1234' - rmock.register_uri('GET', requests_mock.ANY, json=[{"foo": "bar"}], headers={"link":""" - <{base}/api/v1/timelines/tag/{tag}?max_id={_id}>; rel="next", <{base}/api/v1/timelines/tag/{tag}?since_id={_id}>; rel="prev" - """.format(base=api.api_base_url, tag=UNLIKELY_HASHTAG, _id=_id).strip() - }) + rmock.register_uri( + 'GET', + requests_mock.ANY, + json=[{"foo": "bar"}], + headers={ + "link": f"<{api.api_base_url}/api/v1/timelines/tag/{UNLIKELY_HASHTAG}?max_id={_id}>; rel=\"next\", " + f"<{api.api_base_url}/api/v1/timelines/tag/{UNLIKELY_HASHTAG}?since_id={_id}>; rel=\"prev\"" + } + ) resp = api.timeline_hashtag(UNLIKELY_HASHTAG) assert resp._pagination_next['max_id'] == _id diff --git a/tests/test_status.py b/tests/test_status.py index 8461bc3..56e7397 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -203,7 +203,7 @@ def test_scheduled_status_long_part1(api): else: the_medium_term_future = datetime.datetime.now() + datetime.timedelta(minutes=6) pickle.dump(the_medium_term_future.timestamp(), open("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl", 'wb')) - scheduled_toot = api.status_post("please ensure maximum headroom at " + str(the_medium_term_future), scheduled_at=the_medium_term_future) + scheduled_toot = api.status_post(f"please ensure maximum headroom at {the_medium_term_future}", scheduled_at=the_medium_term_future) scheduled_toot_list = api.scheduled_statuses() assert scheduled_toot.id in map(lambda x: x.id, scheduled_toot_list) pickle.dump(scheduled_toot.params.text, open("tests/cassettes_special/test_scheduled_status_long_text.pkl", 'wb')) -- cgit v1.2.3