Posts

Showing posts from October, 2020

How to Use Pytest Library to Test Python Funtions/Modules/Classes/APIS

how to initialize flask while using pytest- this is only for python+flask, other can leave this step from flask import Flask app = Flask(__name__) with app.app_context() :     def funtio():          pass          .... if __name__ == "__main__" : app.run() How to Install PYtest pip intall pytest how to run pytest: to run pytest we have different ways, one is using terminal, other one is using pycharm env setup now i am saying using terminal, open terminal >pytest (its run all test_*.py files) >pytest -v (display verbose_name) >pytest -v -s ( -s display print statement on termianal) >pytest <filename> -v -s (this is excute only specified file) >pytest -k <search_term> -v -s (this will search that <search_term> on funtion/method names, if it match then move to run other wise dis-select) >pytest <file_name> -k <search_term> -v -s >pytest -m <marker> -v -s (...