Pytest Complete Course

From Basics to Advanced Automation Frameworks

With Fixtures, Tags, Hooks, CI/CD & Projects

โ† Back to Training

๐Ÿ“Œ Module 1: Introduction to Pytest (Deep Dive)

# test_basic.py
# Pytest will auto-detect this file because it starts with "test_"
def test_example():
    assert 5 * 5 == 25

๐Ÿงช Module 2: Assertions (Low-Level Details)

def test_string_compare():
    assert "prakura".upper() == "PRAKURA"

def test_exception_message():
    with pytest.raises(ValueError, match="invalid value"):
        raise ValueError("invalid value provided")

๐Ÿ”ง Module 3: Fixtures (Complete Low-Level Deep Dive)

@pytest.fixture(scope="module")
def db_connection():
    print("Connecting to DB...")
    conn = {"status": "connected"}
    yield conn
    print("Closing DB connection")

๐Ÿท๏ธ Module 4: Markers (Full Explanation)

@pytest.mark.regression
@ pytest.mark.skipif(sys.platform == "win32", reason="Not supported on Windows")
def test_platform_feature():
    assert True

๐Ÿ” Module 5: Parametrization (Low-Level + Nested Parametrization)

@pytest.mark.parametrize("username, password", [
    ("admin", "admin123"),
    ("user", "pass123"),
])
def test_login(username, password):
    assert len(username) > 0 and len(password) > 0

๐Ÿ“‚ Module 6: conftest.py (Low-Level Internal Behavior)

# conftest.py
@pytest.fixture
def api_base_url():
    return "https://api.prakura.in/v1"

โš™๏ธ Module 7: Hooks (Internal Execution Flow)

def pytest_runtest_setup(item):
    print(f"Setting up test: {item.name}")

๐Ÿ“ฆ Module 8: Pytest Plugins (Deep Usage)

๐Ÿ“Š Module 9: Reporting & Logging

pytest --html=report.html --self-contained-html

๐Ÿš€ Module 10: CI/CD Integration

๐Ÿงช Module 11: Real-Time Project (End-to-End)