Step 7 - Pytest tutorial: Test fixtures

preview_player
Показать описание

Make your tests more focused by moving sample data to pytest fixtures.

00:00 - Start
00:21 - Make a fixture for a single player
00:40 - Convert the first test to use that fixture
00:58 - Convert the remaining tests to use that fixture
01:14 - Make a fixture for a list of guardians
01:30 - Convert all the tests to use that fixture
01:45 - Make a fixture in the other test file
02:50 - Remove fixtures from individual test files
03:23 - Show PyCharm's support for fixtures

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

Explanations were fast. However, paired with a preliminary reading on Pytest and with some pauses, this video is the one which made me understand the concept as a whole. Thanks a lot!

vincentpelletier
Автор

Lolz it’s like a tutorial where you’re expected to already know what’s happening.

If you’re totally lost though, just realize this is a way to pass your mock data around without having to declare it each time. It’s like assigning the data to a variable, but instead it’s inside the fixture function. The function name of the fixture becomes the variable name passed into your test functions.

This seems like something you’d only do if the fixture data isn’t being changed by the test functions

I also just made all that up.

annetteselman
Автор

I recommend having a look at how CakePHP deals with fixtures using factories:


pabloinberlin
Автор

way way too fast to follow let alone understand.

MrHomer
welcome to shbcf.ru