Really great tutorial! From having little to no idea about how Python Mocks works to now having a good understanding. Time to improve my understanding now through practice, thank you!
That's just what i needed right now. Oleg, thank you! Been watching your channel since 2017, some time supported on patreon, your content never disappoints. You make very clear and understandable explanation on every important nuance, incrementally from easy to advanced stuff. Sometimes I miss, when there are no new videos for a long time :) Big thank you anyway. I personally think that you made a huge, or even biggest contribution(not size, but in terms of quality, for sure) into instructional videos for Russian self-taught python developers, and now for International community. Time ago your videos helped me to learn a lot of things, to get a first paid developer job and etc. Legend!
No one in TH-cam was able to explain this mock with such a simple example. If I could request would you be able to make a series on testing AWS services using mock.
THATS what happened to your previous channel. Such a great surprise to occasionally find out that you are not done with youtube. Since me watching my first video on your channel many things happened, and even after all those years i can definitely say that your material is way beyond the others in terms of quality. Keep it up man
Excellent video - great examples - so simple, but complete, I agree with others that your commentary is incredible. You describe what is going on at every step - both in the code and in the underlying logic. Mocks can be confusing to me and you really help break down the concepts so thoroughly. This is my first experience watching videos by you. I will be back for more! PS - I usually use pytest, but it was helpful to see the more traditional unittest methodology applied to mocks. Translating your code to pytest was a good exercise for a newbie like me.
I'm taking courses that have this topic. I didn't understand anything there at all. However, as soon as I watched the first 10 minutes of your video, everything immediately became clear. Thank you very much!
@@RedEyedCoderClub But it was only introduction. And may be you'll find some time to continue this topic comparing different approaches in mocking. what are advantages if present in module requests_mocking (or responses) comparing with unittest.mock patch. Or creating custom exceptions working with raise_for_status (had some troubles testing them at my work). Thank you very much.
What video should I make next? Any suggestions? Write me in comments! Follow me @: Telegram: t.me/red_eyed_coder_club Twitter: twitter.com/CoderEyed Facebook: fb.me/redeyedcoderclub
The unittest module uses the naming convention of the function to execute the test. So let’s say you just remove the ‘test’ from test_add it wouldn’t be able to execute the function. To wrap up the explanation, the unittest module requires strict naming convention in order for it to execute a particular unit or suite of multiple isolations.
So the patch decorator is possible only because of the unittest import? Can unittest / mock be used to automate testing of any software or only python? Would love to learn to use tools to write more disciplined code! For example, most tools are pricey as their meant for large enterprises, but there seems to be a few open-source / free options.. Requirement Management - rmtoo florath , doorstop-dev / doorstop Static Structural Source Code Analysis (SAST) - clang-tidy , cppcheck Configuration Management / Storage and Version Control System (VCS) - Git, Mercurial, MS TFS, Subversion Continuous Integration (build and test) / Continuous Delivery-Deployment - Jenkins, GitLab CI/CD
It's a good question! First of all you can use more then one @patch decorator @patch('main.one_func') @patch('main.two_func') def test_function(): pass Also you can use patch as a context manager. Smth like this: with patch('main.one_func') as mock_one_func: pass Also you can use patch() inline. Smth like this: mock_one_func = patch('main.one_func').start() ... mock_one_func.stop() It's all about the scope.
А, уже увидел, что это ты и есть) Класс, часто твои ролики на русском смотрю, теперь видать и на английском буду. Кстати, у тебя хороший английский. Долго учил?
Спасибо)) Только в работе как раз необходимость возникла в тестирование углубиться, а тут такой подгон. Спасибо Олег, во многом и благодаря вашим роликам сменил профессию с тренера по футболу, на пайтон разработчика!)
@@RedEyedCoderClub если коротко то можно глянуть на ютубе "Moscow Python Podcast из преподавателя в разработчики". Если чуть длиннее, то переход занял у меня ровно год активного изучения питона. Начал с бесплатных курсов на степике, там же курс по линуксу, затем книги и в том числе делал блоги на джанго и фласке по вашим обучающим видео с русскоязычного канала. Затем платные курсы от создателей подкаста в который меня потом и пригласили. Скажу что то что прошел ваш курс и сделал блог на джанго мне очень пригодилось при прохождении платных курсов. Там суть в том что короткая вводная часть и затем проект на фласке или джанго, я выбрал джанго и чувствовал себя поувереннее своих сокурсников, успешно защитил проект и устроился на работу. Компания у нас небольшая да и в современных реалиях от разработчика при постановке задачи также требуется грамотная систем логирования и тестирование. Вот сейчас углубляюсь в тестирование и логирование также по вашим роликам, так как на курсах этому уделяется очень мало времени.
@@alexdzehil7194 Спасибо большое за ответ. Я вас от всей души поздравляю и желаю вам успехов! Действительно очень здорово, что вы вот так взяли и переключились. Это очень тяжело. Не каждый так может, а вы смогли. Просто прекрасно!
It's an amazing video! You have really broken the concepts into very easily understandable components. Loved your way of explanation! Thanks
Excellent. I was breaking my head on mock and patch.. now its crystal clear.
Really great tutorial! From having little to no idea about how Python Mocks works to now having a good understanding. Time to improve my understanding now through practice, thank you!
You're a saviour man. I had issues with DI and mocks but this video has simplified everything for me. Great explanation!👏
This video is just awesome. I was stuck reading docs and couldn't apply it in my test cases. Thanks a lot for this great explanation.
This is the best explanation ive ever seen in my life+!! You're aweskme
That's just what i needed right now. Oleg, thank you!
Been watching your channel since 2017, some time supported on patreon, your content never disappoints. You make very clear and understandable explanation on every important nuance, incrementally from easy to advanced stuff. Sometimes I miss, when there are no new videos for a long time :) Big thank you anyway. I personally think that you made a huge, or even biggest contribution(not size, but in terms of quality, for sure) into instructional videos for Russian self-taught python developers, and now for International community. Time ago your videos helped me to learn a lot of things, to get a first paid developer job and etc.
Legend!
Thank you very much for your kind words :) Glad that you like my stuff.
+1 !
@@meriem623 Thank you
One of the best vedioes on Python Mocks👏👏👏
No one in TH-cam was able to explain this mock with such a simple example. If I could request would you be able to make a series on testing AWS services using mock.
Fantastic tutorial. Took me from almost no knowlege of python unittest and mocks to very confident. Thank you!
Thank you very much!
Thanks
Thank you very much!
Amazing work! Never thought of pronouncing OK as Awk.
THATS what happened to your previous channel. Such a great surprise to occasionally find out that you are not done with youtube.
Since me watching my first video on your channel many things happened, and even after all those years i can definitely say that your material is way beyond the others in terms of quality.
Keep it up man
Thank you very much!
this is great video, with this one video i wrote my 1st unit test case of my project. Thanks
Thanks for the explanation. The mock is very powerful. I feel conformable starting to use it now
Great explanation. Was struggling with the concept. Now I am confident with the topic
I get a lot of knowledge by watching your video lessons. Thank you very much!
Thank you
This is an interesting video. For more of these in TH-cam 👍👍👍
Thanks for comment
Hello, or privet,
Whatever, thanks ever so much for ur video. Ure superman 👍🏻🌹👍🏻
Thank you!
Great video. The explanations are extremely clear and easy to follow.
that was a amazing video. Thank you!
Thank you!
This has been an awesome video. Thanks a bunch!
Amazing video. Simplified demo on how to write UT with mocks. Thanks
Thanks. Was finding it difficult understanding, U made it clear
hi, i have seen many and many tutos python mocks, but this one is simple, clear and understable. 👍 and many thanks !
Thank you very much!
I am appreciated for this great tutorial!
Thank you!
amazing, I can understand mock and patch now. Thank you so much
Excellent video - great examples - so simple, but complete, I agree with others that your commentary is incredible. You describe what is going on at every step - both in the code and in the underlying logic. Mocks can be confusing to me and you really help break down the concepts so thoroughly. This is my first experience watching videos by you. I will be back for more! PS - I usually use pytest, but it was helpful to see the more traditional unittest methodology applied to mocks. Translating your code to pytest was a good exercise for a newbie like me.
Very good Video. Example chosen is very apt to the real world programming
Thank you!
Exelent !!! Thanks for sharing this!
Great tutorial. Thank you for sharing the knowledge.
Excelent information and examples, thanks bro!
Thank you for the comment!
Great tutorial! thank you for that
Your work is excellent, you help me a lot, thank you!
Thank you
I'm taking courses that have this topic. I didn't understand anything there at all. However, as soon as I watched the first 10 minutes of your video, everything immediately became clear. Thank you very much!
Glad to hear! Thank you for the comment!
This is something new for me. Thank you.
Thank you!
OMG - you have made it so easy !! Thank you so much ❤
Great video!!! Thank you so much.
Thanks for comment!
Very well explained!! Thank you!
🎉 very nice explanation
Excellent explanation! Nice job!
Thank you very much! Have a nice day!
Excellent tutorial. Thanks!
Amazing video! Congrats and thanks a lot!! So helpful!
Thank you! This is a great explanation. :)
Amazing video!
Awesome! Thank you very much!
Thank you for the comment!
Video is great! It was interesting.👍👍👍
Thanks for comment!
Thanks to the author --- interesting video
Thank you!
Thank you for the guide. It's indeed very interesting and useful. Subscribed!
Thank you very much!
Thank you very much for such a detailed and informative video tutorial, this information is very important to me.
Thank you!
thank you so much very informative video
What a gift! Thanks.
Isn't it too basic for you?
@@RedEyedCoderClub But it was only introduction. And may be you'll find some time to continue this topic comparing different approaches in mocking. what are advantages if present in module requests_mocking (or responses) comparing with unittest.mock patch. Or creating custom exceptions working with raise_for_status (had some troubles testing them at my work). Thank you very much.
Yep, that's right. I knew that it's too basic for you, and planned to make more.
This is a helpful video. For me exactly. Thank you.
Thanks for comment!
Cool and clear video tutorial. Thank you this is very helpful.
Thank you!
loved it. Thank you.
Nice explanation
Great explanation!
Thank you, a really helpful video. I like the examples chosen for the video. +1 subscriber
Thanks for the perfect example, I wish I could like more than once 👍
Thank you! There are more videos to like and comment :D
What video should I make next? Any suggestions? Write me in comments!
Follow me @:
Telegram: t.me/red_eyed_coder_club
Twitter: twitter.com/CoderEyed
Facebook: fb.me/redeyedcoderclub
github?
Your work is excellent, thank you!
Thank you for a detailed and informative video tutorial. I look forward to new lessons from you.
Thank you!
Thank you, beautifully explained
Thanks for watching!
The video review is very informative and useful. Thank you.
Thank you!
Great video Thanks
Very good!!!!!
Thank you!
This was so helpful thank you 🙏
Thank you for the video. Always very informative.
Thank you!
Thanks you so much for this interesting and detailed guide. Will there be videos on testing with pytest?
Thank you! Yes, a planned to make videos about pytest. Stay tuned.
Thank you, everything is clear and understandable!
Thank you!
Amazing tutorial. Please make a series on Pytest. Thank you.
Thank you! I'll try!
братишка лучше гайда не видел успехов тебе от души
Nice tutorial
شكرا ❤❤
2:10 How is the test_add() method called?
The unittest module uses the naming convention of the function to execute the test. So let’s say you just remove the ‘test’ from test_add it wouldn’t be able to execute the function. To wrap up the explanation, the unittest module requires strict naming convention in order for it to execute a particular unit or suite of multiple isolations.
thx, crystal clear.
Thank you!
So the patch decorator is possible only because of the unittest import?
Can unittest / mock be used to automate testing of any software or only python?
Would love to learn to use tools to write more disciplined code! For example, most tools are pricey as their meant for large enterprises, but there seems to be a few open-source / free options..
Requirement Management - rmtoo florath , doorstop-dev / doorstop
Static Structural Source Code Analysis (SAST) - clang-tidy , cppcheck
Configuration Management / Storage and Version Control System (VCS) - Git, Mercurial, MS TFS, Subversion
Continuous Integration (build and test) / Continuous Delivery-Deployment - Jenkins, GitLab CI/CD
Дай обниму братюнь, отличный видос, спасибо.
Всегда пожалуйста
Thank you for the video, very clear but how can you mock multiple elements in one function? For example if a function calls two functions.
It's a good question!
First of all you can use more then one @patch decorator
@patch('main.one_func')
@patch('main.two_func')
def test_function():
pass
Also you can use patch as a context manager. Smth like this:
with patch('main.one_func') as mock_one_func:
pass
Also you can use patch() inline. Smth like this:
mock_one_func = patch('main.one_func').start()
...
mock_one_func.stop()
It's all about the scope.
@@RedEyedCoderClub Thank you, I have tried the first two solutions and they work well. Not sure how to use the last one though.
It's great!
Many Thanks. Can we get code written?
Sorry, no. It's just an example
sir how to write unit test for url loding , and websit proper loding
Thanks🙏
Thanks for comment, and have a nice day!
Can you make a video but using Pytest please?
I think the url no longer works for the jokes?
it's a pity, but you can use any other API or a website.
My god, thank you
Thank you for the comment!
Thanks for the video.
I'm facing a error when running the test.py
ModuleNotFoundError: No module named 'main'
Ok, have you the `main.py` module?
What's you directory/files structure?
Did you check your code twice?
Спасибо! Хорошо бы возобновить рубрику "ответы на вопросы") Но уже на английском
Ага, только вопросов что-то не много совсем
Your voice sounds exactly like Oleg Molchanov. Where are you from?
А, уже увидел, что это ты и есть) Класс, часто твои ролики на русском смотрю, теперь видать и на английском буду. Кстати, у тебя хороший английский. Долго учил?
Не знаю, трудно сказать. Думаю если бы занимался систематично и регулярно знал бы его значительно лучше.
Спасибо)) Только в работе как раз необходимость возникла в тестирование углубиться, а тут такой подгон. Спасибо Олег, во многом и благодаря вашим роликам сменил профессию с тренера по футболу, на пайтон разработчика!)
Вау, это круто! Не поделитесь ли историей перехода?
@@RedEyedCoderClub если коротко то можно глянуть на ютубе "Moscow Python Podcast из преподавателя в разработчики". Если чуть длиннее, то переход занял у меня ровно год активного изучения питона. Начал с бесплатных курсов на степике, там же курс по линуксу, затем книги и в том числе делал блоги на джанго и фласке по вашим обучающим видео с русскоязычного канала. Затем платные курсы от создателей подкаста в который меня потом и пригласили. Скажу что то что прошел ваш курс и сделал блог на джанго мне очень пригодилось при прохождении платных курсов. Там суть в том что короткая вводная часть и затем проект на фласке или джанго, я выбрал джанго и чувствовал себя поувереннее своих сокурсников, успешно защитил проект и устроился на работу. Компания у нас небольшая да и в современных реалиях от разработчика при постановке задачи также требуется грамотная систем логирования и тестирование. Вот сейчас углубляюсь в тестирование и логирование также по вашим роликам, так как на курсах этому уделяется очень мало времени.
@@alexdzehil7194 Спасибо большое за ответ. Я вас от всей души поздравляю и желаю вам успехов! Действительно очень здорово, что вы вот так взяли и переключились. Это очень тяжело. Не каждый так может, а вы смогли. Просто прекрасно!
👍👍👍👍👍👍👍👍👍👍👏👏👏👏👏👏👏👏 THANKS
Thanks for comment!
Олег Молчанов енто ты?
Да, это я
@@RedEyedCoderClub узнал по голосу.
Спасибо за отличный контент!
Потдержу тебя чем смогу)
Спасибо! Рад, что нравится
Finally I found great and not arabian tutorial
Great. Just what I was looking for.
Thanks for comment!
This is something new for me. Thank you.
Thanks for comment!
Great explanation and easy to understand, thanks!