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

request のテストに Mock を導入した #37

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

Javakky
Copy link
Owner

@Javakky Javakky commented Nov 9, 2021

nicovideo_api_client/api/v2/result.py のテストはこれまで build_url() で正しいURLが生成されているかしか見ていなかったが、 requests.get を mock することで、返却された値に対して正しい加工が行えているかをテストできるようにした。

参考にしたリンク;https://dev.classmethod.jp/articles/python_unittest_mock/

@Javakky
Copy link
Owner Author

Javakky commented Nov 9, 2021

poetry run task format--exclude が指定されているのは、 black 側が match 構文に対応していなさそうなので暫定措置。対応完了後にこちらも戻す予定。

psf/black#2242

@Javakky Javakky force-pushed the javakky/requests-mock-test-single-case branch from 1350f26 to e8d10b9 Compare November 10, 2021 02:35
@yashiroyrahs
Copy link
Collaborator

メソッドへの置き換えありがとうございます。
いいと思います。

@Javakky Javakky merged commit b684dbb into master Nov 10, 2021
@Javakky Javakky deleted the javakky/requests-mock-test-single-case branch November 10, 2021 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants