ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

How to Test Python's Random Module

Автор: Pybites

Загружено: 2023-05-23

Просмотров: 655

Описание: In this video you'll learn how to effectively test the Python random module using pytest.

We cover strategies for testing code that involves picking random emails with the random sample function (code from previous video put into functions:    • Using a bit of Python to get random emails...  )

We demonstrate the use of len() and all(), but then refactor the tests to use random.seed() to make random functions predictable, ensuring consistent results for testing.

We put random.seed() in a pytest fixture, using autouse=True to run the fixture automatically (that is, we don't pass it into the test function).

Here is an article on pytest fixtures if you're new to them: https://pybit.es/pytest-fixtures.html

A follow up video could be to refactor this test again showing how you could use mocking, just comment below if interested, as well for more Standard Library modules and testing videos ... 💡

Code:
get random emails: https://gist.github.com/bbelderbos/5d...
final tests: https://gist.github.com/bbelderbos/b9...

---
Learn more about Pybites / what we do: https://pybit.es

Get our weekly developer / mindset emails: https://pybit.es/friends/

Join our Slack community: https://pybit.es/community/

And last but not least, we appreciate any feedback to make our YouTube content better 💡
https://form.jotform.com/230941798741062 🙏

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
How to Test Python's Random Module

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Write a Python decorator from scratch to time the execution of a function

Write a Python decorator from scratch to time the execution of a function

Pytest Tutorial – How to Test Python Code

Pytest Tutorial – How to Test Python Code

How To Predict Random Numbers Generated By Computers

How To Predict Random Numbers Generated By Computers

Введение в Python Mocks | Учебник по Python

Введение в Python Mocks | Учебник по Python

Тестовое по retention (python + pandas и SQL) | Ща порешаем! #36

Тестовое по retention (python + pandas и SQL) | Ща порешаем! #36

Unit Testing in Python with pytest

Unit Testing in Python with pytest

Randomness is Random - Numberphile

Randomness is Random - Numberphile

Визуализация внимания, сердце трансформера | Глава 6, Глубокое обучение

Визуализация внимания, сердце трансформера | Глава 6, Глубокое обучение

What is Feature Scaling? | Standardization | Normalization | Data Preprocessing in Python

What is Feature Scaling? | Standardization | Normalization | Data Preprocessing in Python

В 2026 VPN НЕ ПОМОЖЕТ: Роскомнадзор Закрывает Интернет

В 2026 VPN НЕ ПОМОЖЕТ: Роскомнадзор Закрывает Интернет

Как научиться читать мысли по руке

Как научиться читать мысли по руке

Python tests | Pytest Mock and Patch

Python tests | Pytest Mock and Patch

NMCS4ALL: Random number generators

NMCS4ALL: Random number generators

Audio modules for electronics project

Audio modules for electronics project

Dynamic Attribute Handling in Python: getattr(), setattr(), hasattr(), delattr()

Dynamic Attribute Handling in Python: getattr(), setattr(), hasattr(), delattr()

КАК НЕЛЬЗЯ ХРАНИТЬ ПАРОЛИ (и как нужно) за 11 минут

КАК НЕЛЬЗЯ ХРАНИТЬ ПАРОЛИ (и как нужно) за 11 минут

Стоило ли покупать УБИТЫЙ MacBook за 5000₽? Результат ШОКИРОВАЛ! Ремонт MacBook Pro 15 1013 a1398

Стоило ли покупать УБИТЫЙ MacBook за 5000₽? Результат ШОКИРОВАЛ! Ремонт MacBook Pro 15 1013 a1398

Haskell, python и прочие приблуды. Прохожу машину HaskHell на TryHackMe, уровень средний!

Haskell, python и прочие приблуды. Прохожу машину HaskHell на TryHackMe, уровень средний!

Python RANDOM Number Generator Module Tutorial

Python RANDOM Number Generator Module Tutorial

P2P Стриминг через VDO Ninja: Что делать при блокировках Интернета?

P2P Стриминг через VDO Ninja: Что делать при блокировках Интернета?

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]