Testing with pytest
Automated testing ensures code quality and prevents regressions.
Basic Test
# test_example.py
def test_addition():
assert 1 + 1 == 2
def test_string():
assert "hello".upper() == "HELLO"
Fixtures
import pytest
@pytest.fixture
def user():
return {"name": "John", "age": 30}
def test_user_name(user):
assert user["name"] == "John"
Discussion 0
No comments yet. Be the first to start the discussion!
Leave a Comment