Unit Tests with Pytest | Flask and Python Backend #5

preview_player
Показать описание
In this video I show how to write unit tests with Pytest. I show the parametrized tests, the conftest and the fixtures.

Content:
* the pytest dependency;
* the project structure with pytest. Where are located the tests.
* the given when then method to write unit tests;
* the parametrized tests to run a single test with multiple inputs;
* the context to assert that an exception is raised as expected;
* the meaning of the conftest file and the fixtures. How to use the fixtures for the tests setup and teardown;
* and the mock of unittest.

Рекомендации по теме
Комментарии
Автор

Thank you. This is the best tutorial I've found. It's up to date and I think it covers all major components in just 17 minutes.

vahkhachatryan
Автор

Super great materials! Im so gratefull i found this channel! Thank you Sergio!!

eyalbahar
Автор

Hi Sergio, I am very new at testing. I cannot event test for first time. I have a project started and have blueprint and app factory structure similar to yours, but I got ModuleNotFoundError: No module named "name_of_app_folder" every time. Any suggestion?

Автор

this is good. do you have any git url where you have sample code?

amritjain
Автор

hi sergio, I think it miss the scope's fixture for app_with_data, otherwise with bigger test it reload data and we lost id of confest.py objects in db

kuririn
Автор

i tried this and got the error ' RuntimeError: Working outside of application context.'

jamescat