Professional Python Testing with Mocks
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Related videos
Nuitka: The Professional Way To Compile Python
NeuralNine
46.7k views
Automatically Fill Word Files with Python
NeuralNine
38.5k views
Professional Weather App with Django in Python
NeuralNine
52.9k views
Makefiles in Python For Professional Automation
NeuralNine
51.3k views
Professional Expense Tracker in Python
NeuralNine
48.4k views
Optimize Your Python Programs: Code Profiling with cProfile
NeuralNine
53.5k views
Scheduling Tasks Professionally in Python
NeuralNine
107.2k views
Working with YAML Files in Python
NeuralNine
57.1k views
Containerize Python Applications with Docker
NeuralNine
151.3k views
Rotating Proxies For Web Requests in Python
NeuralNine
102.8k views
Top Comments (10)
Most people don't use mocks and they just hope that the database or the internet or whatever other service works during the test run phase. A good use case is when there is expected to get a reponse from the user like in the input() function, the test would just wait until someone input some data and press enter. Mocking the input() function allows the test to run uninterrupted.
That was quite confusing.
English is my second language and the explainings are so clear that I understood everything in this tutorial. Very well explained and examplified. Thank you so much.
This is now my GO TO channel for python. Absolutely top class tutorials!
Nice video! Very didact! I had some problems doing tests in my life as dev and I have one contribution with your video if I may. Mocking tool kits like pytest and unittest obey certain chain order of calls because of test context objects and that can be very tricky for devs, especially if you're trying to test things inside Flask application/session context, for example. The recommendation is mock function/method calls from the module is being tested instead from where it's created. In the case of you example with 'requests.get', the ideal is apply 'patch' in 'module_is_being_tested.requests.get'. That guarantees your patch will mock in the precise moment is needed and will return the mock value as expected. Otherwise, some undesirable values can be returned. Believe me, I loss all my hair being stressed with thing like this.
the explanation from beginning is awesome mahn! Very concise
Very well explained. Please come up with more such videos and examples. Thanks .
Also, to test error conditions it's great to use mocks on the dependencies
That was sensational, feeling 🏋️♀️🏋️♀️
A little chaotic and the examples were very well done.
Unlock the Data Inside
Turn Videos into Knowledge
- Get FREE 10/day: transcripts, summaries, chats
- Chat with videos, export text & PDF
- $1 free API credit for RAG, chatbots & research
Free forever plan • All features unlocked
Top Comments (10)
Most people don't use mocks and they just hope that the database or the internet or whatever other service works during the test run phase. A good use case is when there is expected to get a reponse from the user like in the input() function, the test would just wait until someone input some data and press enter. Mocking the input() function allows the test to run uninterrupted.
That was quite confusing.
English is my second language and the explainings are so clear that I understood everything in this tutorial. Very well explained and examplified. Thank you so much.
This is now my GO TO channel for python. Absolutely top class tutorials!
Nice video! Very didact! I had some problems doing tests in my life as dev and I have one contribution with your video if I may. Mocking tool kits like pytest and unittest obey certain chain order of calls because of test context objects and that can be very tricky for devs, especially if you're trying to test things inside Flask application/session context, for example. The recommendation is mock function/method calls from the module is being tested instead from where it's created. In the case of you example with 'requests.get', the ideal is apply 'patch' in 'module_is_being_tested.requests.get'. That guarantees your patch will mock in the precise moment is needed and will return the mock value as expected. Otherwise, some undesirable values can be returned. Believe me, I loss all my hair being stressed with thing like this.
the explanation from beginning is awesome mahn! Very concise
Very well explained. Please come up with more such videos and examples. Thanks .
Also, to test error conditions it's great to use mocks on the dependencies
That was sensational, feeling 🏋️♀️🏋️♀️
A little chaotic and the examples were very well done.