PyTest - professional tests for your Python code.

Pubblicato il: 16 aprile 2026
sul canale di: Hashtag Programação
6,375
518

🎓 Impressive Community: https://www.hashtagtreinamentos.com/c...
🎓 Impressive Python: https://lp.hashtagtreinamentos.com/es...
📘 Mini-course on creating websites with Python: https://blp.hashtagtreinamentos.com/p...
📁 Files Used in Video:

https://dlp.hashtagtreinamentos.com/p...

-----------------------------------------------------------------------

💻 Recommended Video:
How to Start From Zero in Python Classes - Self and Init Explained
   • Como Sair do Zero em Classes no Python - S...  

-----------------------------------------------------------------------

🧑‍💻 TO HIRE HASHTAG FOR YOUR COMPANY:
https://www.hashtagtreinamentos.com/t...

-----------------------------------------------------------------------

📘 Hey guys, in this video I'll give you a complete tutorial on Pytest, the essential Python tool for professional unit testing.

You'll learn step-by-step how to test robust systems, such as an e-commerce shopping cart, ensuring that updates don't break functionalities like adding products, calculating totals, and applying discounts.

Here I explain the installation, creating tests with asserts, handling errors with raises, fixtures for reusing setups, parameterization for multiple scenarios, and mocks to simulate external APIs without real calls, such as payment gateways. All with practical examples.

🔔 Liked the content? Leave a like, subscribe to the channel, and activate the bell to receive more content about Python, tools, and practical projects.

-----------------------------------------------------------------------

📌 Hashtag Programming

► Subscribe to our channel: https://www.youtube.com/c/HashtagProg...
► Activate notifications (click the bell)!

► Like our video!

-----------------------------------------------------------------------

🔗 Social Media

► Blog: https://www.hashtagtreinamentos.com/blog
► YouTube:    / hashtagprogramacao  
► Instagram:   / hashtagprogramacao  
► Facebook:   / hashtagprogramacao  
► TikTok:   / hashtagprogramacao  

Here on the Hashtag Programação channel, we teach various Python tips so you can develop your skills in this programming language and create your own projects and automations!

-----------------------------------------------------------------------

⏱️ Lesson Content

00:00 Introduction to Pytest
00:15 Manual Testing vs. Pytest
01:25 Lesson Example
01:17 Example of product and cart classes
01:41 Basic Object-Oriented Programming
02:20 Explanation of the lesson code
02:25 Logic for calculating total with discount
03:35 Traditional testing without Pytest
06:33 Problems with traditional testing
08:05 Testing with Pytest - Pytest Installation
08:20 test_ file with test_ functions
09:35 Assert for verification
11:40 Creating new tests with Pytest
13:13 Using Pytest and results
17:23 -v command in Pytest for details
19:29 Adding if/raise ValueError validation
23:11 pytest.raises(ValueError) to test expected errors
26:09 Repetition of Code in Tests
27:34 Fixture @pytest.fixture for full cart
31:18 pytest.parametrize for multiple discounts
37:30 Parameterize for invalid discounts
38:32 Multiple test files (test_carrinho2.py)
39:37 Introduction to Mocks for external APIs
40:01 Example checkout.py and payment_gateway
44:44 Real test problems: fake records, slowness
46:19 Import unittest.mock
48:53 Cart fixture for checkout tests
50:07 Successful purchase test (mock.return_value = True)
53:17 Purchase error test (pytest.raises + mock.return_value = False)
55:49 Verify calls: mock.charge.assert_called_once_with()
59:00 Conclusion

#python #programminghashtag #pytest


In questa pagina del sito puoi guardare il video online PyTest - professional tests for your Python code. della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Hashtag Programação 16 aprile 2026, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 6,375 volte e gli è piaciuto 518 spettatori. Buona visione!