webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

【Python】aiohttpパッケージでWebリクエストを模擬するためのヘルパー「aioresponses」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

【Python】aiohttpパッケージでWebリクエストを模擬するためのヘルパー「aioresponses」のインストールについて解説しています。

「aioresponses(https://github.com/pnuckowski/aioresponses)」は、Web リクエストのテストに役立つPythonライブラリです。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■aioresponsesをインストールする

aioresponsesをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install aioresponses

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install aioresponses

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting aioresponses

Downloading aioresponses-0.7.4-py2.py3-none-any.whl (10 kB)

Collecting aiohttp<4.0.0,>=2.0.0

Downloading aiohttp-3.8.4-cp38-cp38-win_amd64.whl (324 kB)

---------------------------------------- 324.5/324.5 kB 1.0 MB/s eta 0:00:00

Collecting yarl<2.0,>=1.0

Using cached yarl-1.8.2-cp38-cp38-win_amd64.whl (56 kB)

Collecting multidict<7.0,>=4.5

Using cached multidict-6.0.4-cp38-cp38-win_amd64.whl (28 kB)

Collecting frozenlist>=1.1.1

Using cached frozenlist-1.3.3-cp38-cp38-win_amd64.whl (34 kB)

Collecting aiosignal>=1.1.2

Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)

Collecting attrs>=17.3.0

Using cached attrs-22.2.0-py3-none-any.whl (60 kB)

Collecting charset-normalizer<4.0,>=2.0

Downloading charset_normalizer-3.0.1-cp38-cp38-win_amd64.whl (95 kB)

---------------------------------------- 95.8/95.8 kB 909.8 kB/s eta 0:00:00

Collecting async-timeout<5.0,>=4.0.0a3

Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)

Collecting idna>=2.0

Using cached idna-3.4-py3-none-any.whl (61 kB)

Installing collected packages: charset-normalizer, multidict, idna, frozenlist, attrs, async-timeout, yarl, aiosignal, aiohttp, aioresponses

Successfully installed aiohttp-3.8.4 aioresponses-0.7.4 aiosignal-1.3.1 async-timeout-4.0.2 attrs-22.2.0 charset-normalizer-3.0.1 frozenlist-1.3.3 idna-3.4 multidict-6.0.4 yarl-1.8.2

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、aioresponsesが正常にインストールされたことになります。

なお、今回はaioresponsesのバージョン0.7.4をインストールしました。