S SmartDocs
Chuỗi bài: python old python 17 dòng · Cập nhật 2026-02-03

test_text_utils.py

python_old/pytest-workshop/pytest-workshop-solutions/tests/test_text_utils.py

import pytest
from src.text_utils import slugify

@pytest.mark.parametrize("inp,expected", [
    ("Hello World", "hello-world"),
    ("  multiple   spaces  ", "multiple-spaces"),
    ("Symbols!@#$", "symbols"),
    ("MiXeD-Case", "mixed-case"),
    ("", ""),
    ("   ", ""),
], ids=["basic","spaces","symbols","case","empty","spaces-only"])
def test_slugify(inp, expected):
    assert slugify(inp) == expected

@pytest.mark.xfail(reason="accent stripping not implemented", strict=False)
def test_slugify_accents():
    assert slugify("Café à la carte") == "cafe-a-la-carte"

Bài viết liên quan