- Command-line tool that automatically finds tests you've written, run the tests and reports the results.
- Can be used by development teams, QA teams, individuals practicing TDD and open source projects.
- Project all over internet switched from unittest or nose to pytest, including Mozilla and Dropbox.
- Simple tests are simple to write in pytest.
- Complex tests are still simple to write.
- Tests are easy to read.
- Tests are easy to read. (So important it’s listed twice.)
- You can get started in seconds.
- You use assert to fail a test, not things like self.assertEqual() or self.assertLessThan(). Just assert.
- You can use pytest to run tests written for unittest or nose.
python -m venv .venv
source .venv/bin/activate export PYTHONPATH=$PYTHONPATH:$(pwd)/pytest_presentationpython -m pip install -r requirements.txtpytest -v tests/test_1_intro.pypytest -v tests/test_2_add.pypytest -v tests/test_3_exceptions.pypytest -v tests/test_4_parametrize.pypytest -v tests/test_5_skip.pypytest -v tests/test_1_intro.pypytest -v tests/test_1_intro.py::test_value_in_listpytest -v tests/func/pytest -v tests/func/test_6_integration.py::TestIntegrationpytest -v tests/func/test_6_integration.py::TestIntegration::test_list_taskspytest -v -k taskpytest -v tests/test_7_fixtures.py-
pytest-cov
-
pytest-django
-
pytest-mock
-
pytest-env
-
pytest-freezegun
-
pytest-repeat: Run Tests More Than Once
-
pytest-xdist: Run Tests in Parallel
-
pytest-timeout: Put Time Limits on Your Tests
-
pytest-instafail: See Details of Failures and Errors as They Happen
-
pytest-sugar: Instafail + Colors + Progress Bar
-
pytest-emoji: Add Some Fun to Your Tests
-
pytest-html: Generate HTML Reports for Test Sessions
-
pytest-pycodestyle, pytest-pep8: Comply with Python’s Style Guide
-
pytest-flake8: Check for Style Plus Linting
-
pytest-selenium: Test with a Web Browser
-
pytest-django: Test Django Applications
-
pytest-flask: Test Flask Applications
Plugins from Docs Plugins Compatíveis
python -m pip install pytest-mock pytest -v tests/test_8_mocker.pypython -m pip install pytest-covpytest -v --cov=pytest_presentation tests/pytest -v --cov-report html --cov=pytest_presentation tests/pytest --no-covPalestra - Rafael Henrique (PyBR 2019)