Тёмный

Python Unit Testing | FastAPI with Pytest Tutorial (fast & easy) 

Eric Roby
Подписаться 9 тыс.
Просмотров 16 тыс.
50% 1

How to implement Python Unit Testing framework, Pytest , into your FastAPI application easily. Write better Python API code!
💻 Git Repository: www.codingwith...
🎥 React + FastAPI: • How to build a React +...
🎥 AWS Lambda + FastAPI: • Deploy FastAPI on AWS ...
🎥 MongoDB + FastAPI: • Unlocking the Power of...
🎥 MySQL + FastAPI: • How to build a FastAPI...
🎥 PostgreSQL + FastAPI: • How to build a FastAPI...
🎓 Courses can be found:
FastAPI Beginner & Advanced: www.udemy.com/...
Learn Chatbot Development: www.udemy.com/...
🛒 GEAR & RECOMMENDED BOOKS: kit.co/codingw...
👨‍💻 Hi, I am Eric!👨‍💻
Hey! I’m a seasoned developer and Cloud enthusiast. I love sharing my knowledge and helping others to discover the exciting world of programming and cloud technologies. For more tutorials, tips, and tech magic, don’t forget to hit that subscribe button and ring the bell for notifications!
🙏 Support The Channel 🙏
If you found this tutorial helpful, please give it a thumbs up 👍, comment, and share it with your network 🌍
PS: The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you.
#fastapi #python #sqlinjection

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

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@laszlomagyar3156
@laszlomagyar3156 Год назад
The quality of your content is amazing! Keep up the good work!
@codingwithroby
@codingwithroby Год назад
I’m so glad you enjoy it 🙂
@vatsal_gamit
@vatsal_gamit 8 месяцев назад
This is my first video on tests in python and its worth watching !! Keep doing the great work man!! 🙌🏼
@codingwithroby
@codingwithroby 7 месяцев назад
Thanks, will do!
@prasenjitgiri919
@prasenjitgiri919 9 месяцев назад
are you runnig the main,py before running the test ? and what if the main.py file reads from os environment variables - how do you handle it without running the main file? - btw, great video!
@h3ct0rjs
@h3ct0rjs 8 месяцев назад
Thanks for this, have you test Tavern which can be used to run this test to using yaml and python ?
@codingwithroby
@codingwithroby 7 месяцев назад
Oh interesting - I have never seen this before.
@tenzingyatso5096
@tenzingyatso5096 8 месяцев назад
Nice! Could you make the same with async test and test db (postgres)?
@Ruthwikranganathbethapudi
@Ruthwikranganathbethapudi 11 месяцев назад
How to unit test a FastAPI which is connected to Sqlite?
@davidinawe791
@davidinawe791 7 месяцев назад
Hello. I have a question for fastapi testing with pytest and if someone could help me it would be very much appreciated! Essentially, what I need to do within my test is to simulate a server restart. But I do not understand how the server is actually started in pytest. We are running our API with hypercorn. Hypercorns serv() function in our main.py takes the app as a parameter and from my understanding runs the server like you normally would with "hypercorn main:app" by just running the main.py. I just don't understand how the server is actually started with pytest. All we do in pytest (same as in this video) is to define the TestClient, but from my understanding the TestClient is only the one ACCESSING the server that is already running. Therfore I don't know how I could simulate a restart of the server in pytest (like stopping and restarting the execution of "hypercorn main:app" in cmd). Could anyone help me out here and tell me what I am misunderstanding?
@zeldacamila
@zeldacamila 5 месяцев назад
How to unit test a FastAPI which is connected to postgresql, on a CI environment (using github actions)??
@codingwithroby
@codingwithroby 5 месяцев назад
Same way - I'd suggest use SQLite3 and create a separate testing database and not use a production database like PostgreSQL or MySQL
@nuri3029
@nuri3029 10 месяцев назад
Great! Thank you
@codingwithroby
@codingwithroby 10 месяцев назад
You’re welcome! I am glad you found value 🙂
@amadzarak7746
@amadzarak7746 3 месяца назад
Great vid!
@codingwithroby
@codingwithroby 3 месяца назад
Thank you sir!
@hemantgiri2377
@hemantgiri2377 Год назад
sir, please make a video on fastapi with mvc architecture with celery and and redis.
@codingwithroby
@codingwithroby Год назад
Not a bad idea 🙂
@adithyayelloju8296
@adithyayelloju8296 6 месяцев назад
When test cases become larger, How to refactor them?
@codingwithroby
@codingwithroby 4 месяца назад
Structure by business functionality. If you are testing more than 1 thing, break it into two tests.
@CodingStudio
@CodingStudio 11 месяцев назад
but this is not unittesting? this is integration tests?
@codingwithroby
@codingwithroby 11 месяцев назад
Well, you are not completely wrong. This would be considered integration testing but we do not really have a service layer here so it incorporates them both.
Далее
GENIUS FOOD HACKS 🍰 #shorts
00:36
Просмотров 17 млн
ТИПИЧНОЕ ПОВЕДЕНИЕ МАМЫ
00:21
Просмотров 1,1 млн
Learn Docker to Make Deployment Easy (step-by-step)
10:28
How To Write Unit Tests in Python • Pytest Tutorial
35:34
Pytest Tutorial - How to Test Python Code
1:28:39
Просмотров 203 тыс.
Pydantic Has Saved Me Countless Hours Of Debugging
14:52
GENIUS FOOD HACKS 🍰 #shorts
00:36
Просмотров 17 млн