Pytest Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Pytest =Executing A Single Test=")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=
* [[Pytest#Subjects|Pytest]]
* [[Pytest#Subjects|Pytest]]
=Running pytest As a Module=
<syntaxhighlight lang='bash'>
python -m pytest
</syntaxhighlight>
=Running from Command Line, Automatically Detecting Tests=
Install <code>pytest</code> as described here: {{Internal|Pytest Installation#Overview|pytest Installation}}
=Executing A Single Test=
=Executing A Single Test=
==Executing a Single Test in a Module==
<syntaxhighlight lang='bash'>
pytest test_mod.py::test_func
</syntaxhighlight>
==Executing a Single Test in a Class==
<syntaxhighlight lang='bash'>
pytest test_mod.py::TestClass::test_method
</syntaxhighlight>
==Generate Report==
<syntaxhighlight lang='bash'>
./venv/bin/pip install pytest-html
pytest --html=~/tmp/report.html
</syntaxhighlight>

Latest revision as of 20:47, 25 July 2023

Internal

Running pytest As a Module

python -m pytest

Running from Command Line, Automatically Detecting Tests

Install pytest as described here:

pytest Installation

Executing A Single Test

Executing a Single Test in a Module

pytest test_mod.py::test_func

Executing a Single Test in a Class

pytest test_mod.py::TestClass::test_method

Generate Report

./venv/bin/pip install pytest-html
pytest --html=~/tmp/report.html