Contains pytest scripts which helps in understanding different pytest functionalities and features.
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
An example of a simple test:
# content of test_sample.py
def inc(x):
return x + 1
#make sure the test function's name starts with 'test_'
def test_answer():
assert inc(3) == 5
-
Clone/download this repo
-
Install all the dependencies using-
pip install -r requirements.txt
- Tests are located inside
src/tests/
pytest src/tests
- To run tests and generate html report
pytest src/tests --html=report.html --self-contained-html
- To run tests and generate allure report
#make sure report directory exists in the root folder
pytest src/tests --alluredir=report/
#To view the allure report
allure serve report/
- To run tests with code coverage report
pytest --cov=src --verbose
- To run tests with multiple cpu cycles(will speed up the test execution by running them in parallel)
pytest src/tests -n 5
- To fix liniting errors the project uses autopep8. To modify a file in place (with aggressive level 2):
$ autopep8 --in-place --aggressive --aggressive <filename>