Skip to content

gph/pytest-requests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

API unittest with PyTest

Simple example how to mock module requests using PyTest.

How to run?

$ pytest
================================= test session starts =================================
platform win32 -- Python 3.10.5, pytest-7.2.1, pluggy-1.0.0
rootdir: C:\Users\gph19\Desktop\pytest-api-unittest
plugins: cov-4.0.0, mock-3.10.0
collected 3 items

tests\test_get_data.py ...                                                       [100%] 

================================== 3 passed in 0.10s ==================================

How to check coverage?

$ pytest --cov
================================= test session starts =================================
platform win32 -- Python 3.10.5, pytest-7.2.1, pluggy-1.0.0
rootdir: C:\Users\gph19\Desktop\pytest-api-unittest
plugins: cov-4.0.0, mock-3.10.0
collected 3 items

tests\test_get_data.py ...                                                       [100%]

---------- coverage: platform win32, python 3.10.5-final-0 -----------
Name                     Stmts   Miss  Cover
--------------------------------------------
main.py                      9      0   100%
tests\__init__.py            0      0   100%
tests\test_get_data.py      20      0   100%
--------------------------------------------
TOTAL                       29      0   100%


================================== 3 passed in 0.22s ================================== 

About

Example how to mock requests with PyTest

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages