RUVIDEO
Поделитесь видео 🙏

How To Run Pytest Tests In Parallel (2 Min) | Python Unit Testing

📁 Обучение 👁️ 17 📅 02.12.2023

In this tutorial, you'll learn how to run Python Pytest Tests in parallel.

Facebook: https://www.facebook.com/GokceDBsql

Video Transcript:

Connect MySQL In Python: https://www.youtube.com/watch?v=0qBctY82et0

Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to run Python tests in parallel using PI tet. Let's start by clicking on the Python packages tab and ensure that the PI test and PI test dash x disk packages are installed in the tests folder.

I have two test files containing two tests each. In the first test file I'm testing the cash sales report and asserting whether the keyword select appears in the first query and the keyword XYZ appears in the second query or not. Similarly in the second test file, I'm testing the lead report and I'm asserting wether the select and XYZ keywords appear in the first query and the second query respectively.

To run these tests sequentially right click on the tests folder then hit run the PI test. Since we have four tests in total and every test will sleep for two seconds, the total execution time should be around 8 seconds. To run these tests in parallel click on the PI test dropdown and then hit edit configuration.

In the additional argument, the section enters dash n4. Here 4 represents the number of CPU cores you want to test to spread across. Click ok to exit then hit the run button to run these tests in parallel. As you can see the execution time for all four tests was only two seconds.

Another way to run tests in parallel is to create a PI test.file in your test folder. Start by creating a PI test section and then write add opts equal to dash n4. Where add opts stands for additional options.

If you run the test again it should only take around 2 seconds. If I reduce the number of CPU cores to 2 then it should take around 4 seconds. To export, the test results click on the export test results button.

One thing to note is that if you run tests in parallel then the ordering of tests will be off as you can imagine. There you have it. Make sure you like, subscribe, and turn on the notification bell.

Until next time.


pytest.ini
[pytest]
addopts = -n2

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How To Run Pytest Tests In Parallel (2 Min) | Python Unit Testing», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.