テスト結果のHTMLレポートを生成する「pytest-html」のインストールについて解説しています。
pytest-htmlライブラリは、テスト結果のHTMLレポートを生成するpytestのプラグインです。pytestは、Pythonのテストツールの1種です。
■Python
今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)
■pytest-htmlをインストールする
pytest-htmlをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。
pip install pytest-html
起動後、上記のコマンドを入力し、Enterキーを押します。
なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。
py -3.8 -m pip install pytest-html
切り替えるために、上記のコマンドを入力し、Enterキーを押します。
Defaulting to user installation because normal site-packages is not writeable Collecting pytest-html Downloading pytest_html-3.1.1-py3-none-any.whl (14 kB) Collecting pytest!=6.0.0,>=5.0 Downloading pytest-6.2.4-py3-none-any.whl (280 kB) |████████████████████████████████| 280 kB 939 kB/s Collecting pytest-metadata Downloading pytest_metadata-1.11.0-py2.py3-none-any.whl (10 kB) Requirement already satisfied: attrs>=19.2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest!=6.0.0,>=5.0->pytest-html) (21.2.0) Collecting py>=1.8.2 Downloading py-1.10.0-py2.py3-none-any.whl (97 kB) |████████████████████████████████| 97 kB 1.7 MB/s Collecting atomicwrites>=1.0; sys_platform == "win32" Downloading atomicwrites-1.4.0-py2.py3-none-any.whl (6.8 kB) Requirement already satisfied: colorama; sys_platform == "win32" in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest!=6.0.0,>=5.0->pytest-html) (0.4.4) Requirement already satisfied: toml in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest!=6.0.0,>=5.0->pytest-html) (0.10.2) Collecting iniconfig Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB) Requirement already satisfied: packaging in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest!=6.0.0,>=5.0->pytest-html) (20.9) Collecting pluggy<1.0.0a1,>=0.12 Downloading pluggy-0.13.1-py2.py3-none-any.whl (18 kB) Requirement already satisfied: pyparsing>=2.0.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from packaging->pytest!=6.0.0,>=5.0->pytest-html) (2.4.7) Installing collected packages: py, atomicwrites, iniconfig, pluggy, pytest, pytest-metadata, pytest-html Successfully installed atomicwrites-1.4.0 iniconfig-1.1.1 pluggy-0.13.1 py-1.10.0 pytest-6.2.4 pytest-html-3.1.1 pytest-metadata-1.11.0
Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pytest-htmlが正常にインストールされたことになります。
なお、今回はpytest-htmlのバージョン3.1.1をインストールしました。
コメント