Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть PYTEST CHEAT SHEET | PART 3 | QA SDET

  • Viplove QA - SDET
  • 2025-05-14
  • 435
PYTEST CHEAT SHEET | PART 3 | QA SDET
  • ok logo

Скачать PYTEST CHEAT SHEET | PART 3 | QA SDET бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно PYTEST CHEAT SHEET | PART 3 | QA SDET или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

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

Cкачать музыку PYTEST CHEAT SHEET | PART 3 | QA SDET бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео PYTEST CHEAT SHEET | PART 3 | QA SDET

Basic Test Structure

Pytest test functions must start with test_.

To run all tests: pytest

Run a specific file: pytest test_login.py

Run a specific test by keyword: pytest -k "test_login"

Use -v for verbose, -s to show print statements, and -x to stop at first failure.

Use --maxfail=2 to stop after 2 failures.



---

🧪 Assertions

Pytest uses plain assert for validations: assert a == b, assert "text" in str.

For exception handling, use:

with pytest.raises(ZeroDivisionError):
1 / 0



---

🔁 Parametrization

Run one test with multiple inputs using @pytest.mark.parametrize:

@pytest.mark.parametrize("x, y", [(1, 2), (3, 4)])
def test_add(x, y):
assert x y



---

🧩 Fixtures

Fixtures are reusable setup/teardown logic:

@pytest.fixture
def setup_data():
return "some data"

Use yield in fixtures to define teardown steps:

@pytest.fixture
def browser():
driver = webdriver.Chrome()
yield driver
driver.quit()

Fixture scopes: function (default), class, module, session

Set autouse=True to run a fixture for every test automatically.



---

🚫 Skipping & xfail

To skip a test:

@pytest.mark.skip(reason="Not implemented yet")

Conditionally skip:

@pytest.mark.skipif(sys.platform == "win32", reason="Skip on Windows")

Expected failure (does not fail build):

@pytest.mark.xfail(reason="Known issue")



---

🧷 Test Organization

Test discovery looks for files named test_*.py or *_test.py.

Functions must begin with test_.

You can also use setup_module(), setup_class(), and setup_function() for old-style setup, but fixtures are recommended.



---

🛠️ Command Line Tools

Run only failed tests: pytest --lf

Rerun failed tests: pytest --reruns 3 (requires pytest-rerunfailures)

Generate HTML reports: pytest --html=report.html (requires pytest-html)

Use --tb=short for a shorter traceback display.



---

🧪 Selenium with Pytest

Create a WebDriver fixture in conftest.py:

@pytest.fixture
def browser():
driver = webdriver.Chrome()
driver.maximize_window()
yield driver
driver.quit()

Use WebDriverWait and expected_conditions for stable waits:

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "username")))

For headless testing:

options = Options()
options.add_argument("--headless")



---

🌐 API Testing with Requests

Install: pip install requests

Example GET request:

import requests
def test_api():
res = requests.get("https://reqres.in/api/users/2")
assert res.status_code == 200

Use @pytest.mark.parametrize to test multiple inputs:

@pytest.mark.parametrize("user_id", [1, 2, 3])
def test_user_api(user_id):
response = requests.get(f"https://reqres.in/api/users/{user_id}")
assert response.status_code == 200



---

🏷️ Markers

Use markers to tag tests:

@pytest.mark.smoke
def test_something():
...

Run specific marker: pytest -m smoke

Register custom markers in pytest.ini:

[pytest]
markers =
smoke: Smoke tests
regression: Regression tests



---

🔌 Useful Plugins

pytest-html: Generate HTML reports.

pytest-xdist: Run tests in parallel (pytest -n 4).

pytest-rerunfailures: Automatically retry failed tests.

Комментарии

Информация по комментариям в разработке

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

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

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