File size: 1,012 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import pytest
from yarl import URL
PATHS = [
# No dots
("", ""),
("/", "/"),
("//", "//"),
("///", "///"),
# Single-dot
("path/to", "path/to"),
("././path/to", "path/to"),
("path/./to", "path/to"),
("path/././to", "path/to"),
("path/to/.", "path/to/"),
("path/to/./.", "path/to/"),
# Double-dots
("../path/to", "path/to"),
("path/../to", "to"),
("path/../../to", "to"),
# absolute path root / is maintained; tests based on two
# tests from web-platform-tests project's urltestdata.json
("/foo/../../../ton", "/ton"),
("/foo/../../../..bar", "/..bar"),
# Non-ASCII characters
("μονοπάτι/../../να/ᴜɴɪ/ᴄᴏᴅᴇ", "να/ᴜɴɪ/ᴄᴏᴅᴇ"),
("μονοπάτι/../../να/𝕦𝕟𝕚/𝕔𝕠𝕕𝕖/.", "να/𝕦𝕟𝕚/𝕔𝕠𝕕𝕖/"),
]
@pytest.mark.parametrize("original,expected", PATHS)
def test__normalize_path(original, expected):
assert URL._normalize_path(original) == expected
|