Quick Tip
Python pytest examples:
# Basic test
def test_addition():
assert 1 + 1 == 2
# Test with fixtures
@pytest.fixture
def sample_data():
return {'name': 'Alice', 'age': 30}
def test_sample(sample_data):
assert sample_data['name'] == 'Alice'
# Parametrize tests
@pytest.mark.parametrize("input,expected", [
(1, 2),
(2, 4),
(3, 6),
])
def test_multiply(input, expected):
assert input * 2 == expected
Powered by MonkeyCode: https://monkeycode-ai.net/
Top comments (0)