Python unit testing - pytest fixtures

preview_player
Показать описание
This tutorial covers a powerful feature in pytest framework called fixtures. It leverages the dependency injection concept for setup and teardown of your unit tests. It is preferred over traditional xunit style setup/teardown methods. The video explains demonstrating problem, issues with test case in the case of code repetition, creating expensive DB connection in every test case and solving problems with fixtures.

Topics that are covered in this Python Video:
0:00 Overview
0:16 Demonstrating problem
3:25 Issues with test case 1. code repetition 2. creating expensive DB connection in every test case
4:32 Setup and teardown methods
7:05 Solving problem with fixtures
9:24 fixtures leverage a concept Dependency injection

Next Video:

Рекомендации по теме
Комментарии
Автор

This is probably the most effective pytest fixtures tutorial I have encountered. You've just made my job a lot easier. Thank you. Your python video series is top notch.

hugh
Автор

4 years old and the best video I've seen on fixtures

BM-ufpp
Автор

There's a lack of pytest video tutorials, and though you haven't covered too many of the pytest features, I'm grateful for the ones you've done so far. Keep it up!

jadsayegh
Автор

You can also use '-s' which is short for '--capture=no'

markph
Автор

Thanks for the great video. One thing to consider, when using fixture with scope="module": You should only test methods of your class that do not modify the object returned by the function, cur in your case (for example a method that adds an attribute to the object). The reason is that you want your tests to be independent, which is not possible, if the test modifies the object that is used in another test.

alexandergawrilow
Автор

For some reason it took me too long to find exactly this video. Great job and thank you!

joem
Автор

Best tutorial for fixtures. Smart use of generator.

devendratapdia
Автор

You are a life saver. I was struggling to understand fixtures. Thanks!

aswinckr
Автор

Amazing video. I am new to Python and was finding it difficult to understand fixtures. The initial section of the video set up up the context nicely in terms of the motivation behind fixtures. Finished it nicely with the optimization in the end by using module scope and cleaning things up. Thanks.

akkineniajay
Автор

I love this: thank you! I spent 30 minutes trying to understand fixtures from some pages I read but your video even at double speed gave me a whole lot more. 7 minutes very well spent!

JulianHarris
Автор

Excellent video. I watched a different video before, but had issues making fixtures to work. I was able to use fixtures to setup and teardown database connections with your lecture. Thank you very much!

quangvo
Автор

you totally nailed it with this tutorial. I had no idea just a few mins ago, now I can accomplish my task. Thank you very much!

vmramirez
Автор

Explained fixtures very well.I was looking for this one. Big thanks!

banhishikhamitra
Автор

Nice tutorial. fixtures added to my knowledge base. Once again thanks for great tutorial.

shrikantsinghraghuwanshi
Автор

Thanks, you explained it beautifully!

cesaritoflores
Автор

thank you so much with this video. It is straight to the point and I now understand how to use fixtures! good job!

martus
Автор

Great video. Exactly what I needed. thanks!

kangeraga
Автор

Good tutorial. This is exactly what I was looking for. Thanks!

BodoSchoenfeld
Автор

Awesome tutorials. Very easy to understand. Appreciate your efforts.
When are you uploading the next video? If I had to suggest a topic, it had be on plugins and hooks. I really want to understand this from the basics. I had sincerely appreciate this.
Thanks, again.

shreyashah
Автор

Nice and easy. Great tutorial thanks :D

gatheringwithin