Тёмный

python cli tested with pytest - (beginner to intermediate) anthony explains  

anthonywritescode
Подписаться 42 тыс.
Просмотров 21 тыс.
50% 1

Опубликовано:

 

24 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 40   
@ShawkingIT
@ShawkingIT 2 года назад
Such a simple idea, but really enjoyed how you built it into a full script. Filled in blanks for me of how to test and use cases for raising exceptions. Great video. Thank you.
@thomashirtz
@thomashirtz 3 года назад
Saying that your videos are amazing would be an understatement :) thanks for the explanation!
@anthonywritescode
@anthonywritescode 3 года назад
glad you're enjoying them!
@grzegorzryznar5101
@grzegorzryznar5101 3 года назад
I found ypur channel on the recommendation of a colleague and I am very glad, cause I have learned a lot of new things from these video! Thanks :)
@anthonywritescode
@anthonywritescode 3 года назад
glad you're enjoying it!
@devopsislove
@devopsislove 10 месяцев назад
thank you Anthony! You definitely have a talent for explaining complex things in simple language
@GabrieleBonetti
@GabrieleBonetti 4 года назад
Continuing on the pytest path, an interesting advanced one would be fixtures and dependency injection By the way, this is great content. Cheers
@defectdefect322
@defectdefect322 3 года назад
ALL python coders should watch your videos
@jrib
@jrib 3 года назад
I would love to see a video on the best/most common use cases for fixtures in pytest!
@anthonywritescode
@anthonywritescode 3 года назад
I have plans to do a thing on fixtures at some point!
@jrib
@jrib 3 года назад
@@anthonywritescode Nice! Looking forward to it.
@sadhlife
@sadhlife 4 года назад
any reason why you didn't import Optional and Sequence in a single line import?
@anthonywritescode
@anthonywritescode 4 года назад
yep! that's covered in ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Sjor8PZXnaw.html
@pustemapustema6497
@pustemapustema6497 3 года назад
I use python for five years , your videos are t h e best
@starshipx1282
@starshipx1282 2 года назад
a lot of very useful info presented very nicely. Thank you anthony.
@selvakumars6487
@selvakumars6487 3 года назад
Awesome work, Thanks Anthony
@d3stinYwOw
@d3stinYwOw 2 года назад
Looks great! Will you plan on some tutorials how to do TDD (Test Driven Development) in practice?
@anthonywritescode
@anthonywritescode 2 года назад
I did already! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-JmMxU8ljiOg.html
@ulfsjodin7872
@ulfsjodin7872 3 года назад
I found a very good example in this video: "testing output with pytest (beginner - intermediate) anthony explains #246" Thanks again for pytest examples that is not (for me) overly advanced. Wonderful explanation of argparse which I am trying to learn at the moment. And a suprisingly simple way of testing it. At least in the beginning. But now I can start from there and learn the rest. Do you have any examples how to test sys? import sys def names(): filename, first, last = sys.argv print(f"Welcome {first} {last}.") How do I test this? I have been searching solutions for days on the internet. They all are too advanced for me. And not really what I am looking for. Your solution seems to be close. For the argparse it was perfect.
@anthonywritescode
@anthonywritescode 3 года назад
you can monkeypatch using the `unittest.mock` module: ```python from unittest import mock with mock.patch.object(sys, 'argv', ['prog', 'first', 'last']): ... ```
@ulfsjodin7872
@ulfsjodin7872 3 года назад
@@anthonywritescode Hello Anthony. I have tried for a week now without any success. Not all the time of course. I am just a hobby pythonista. Doing a little bit now and then If you can give me a little bit more hints I would be glad. Challenges are great for developement. So dont give all of the answer.
@anthonywritescode
@anthonywritescode 3 года назад
what are you stuck on?
@ulfen69
@ulfen69 3 года назад
@@anthonywritescode Do I need a @mock.patch…? Or capsys in the def test_sys():? And is there a readouterr() I assert something to?
@anthonywritescode
@anthonywritescode 3 года назад
if you want to reliably change `sys.argv` without polluting other tests then yes use `mock.patch.object` -- I prefer the context manager over the decorator (less magical, more tightly scoped). capsys is needed if you want to test output
@vinzent1992
@vinzent1992 4 года назад
awesome quick intro to cli, learned some new stuff. How about talking about asyncio next? ;D
@anthonywritescode
@anthonywritescode 4 года назад
I don't know that much about asyncio, but maybe I could do like a hello world program or something -- stay tuned!
@vinzent1992
@vinzent1992 4 года назад
@@anthonywritescode will definitely stay tuned 👍.. Hello worlds are plentiful though, am having a harder time finding useful real-world examples 😉..
@nomik
@nomik Месяц назад
Awesome tutorial!
@jimigrok
@jimigrok 4 года назад
nice explanation !
@konradbeck101
@konradbeck101 4 месяца назад
argparse throws an error if pass in an empty string python hello.py "" hello.py: error: the following arguments are required: person
@anthonywritescode
@anthonywritescode 4 месяца назад
are you on windows? that should work fine I think (an empty string is a valid command line parameter)
@konradbeck101
@konradbeck101 4 месяца назад
@anthonywritescode Yes, I'm on windows. Ended up just using " ", so on to the next video.
@SC-ee5zc
@SC-ee5zc 2 года назад
damn u r good , thanks
@JohnZakaria
@JohnZakaria Год назад
I find the background music a bit distracting, Maybe I am not used to it in your videos..
@anthonywritescode
@anthonywritescode Год назад
good news, it's gone after the first couple videos
@OldOneX
@OldOneX 3 года назад
انته ❣️
@tkm3ss10
@tkm3ss10 3 года назад
At 03:55, you can change the index to 0 to remove the index error and to 2 to get 2nd name, Jeff.
@anthonywritescode
@anthonywritescode 3 года назад
that doesn't fix anything, it breaks the point of the program -- `argv[0]` is the name of the program itself
@Walruz1000
@Walruz1000 4 года назад
I noticed that in python multiple return statements seem to be accepted, whereas in all the java projects I worked on in the past the sonar builds would fail for this. What is your opinion on that?
@anthonywritescode
@anthonywritescode 4 года назад
I think they're mostly fine -- there are places where multiple return statements can be confusing (and easy to miss one case or another) but as long as a type checker (such as mypy) is set up you're ~mostly guarded against being a problem. imo it's really only an issue when functions get too long and one return statement might be lost further up
Далее
ŠKODA не перестает удивлять
00:48
Просмотров 291 тыс.
impossible lungs test !! 🫁
01:00
Просмотров 6 млн
25 nooby Python habits you need to ditch
9:12
Просмотров 1,8 млн
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 811 тыс.
ŠKODA не перестает удивлять
00:48
Просмотров 291 тыс.