|
import pytest |
|
|
|
from yarl import URL |
|
|
|
PATHS = [ |
|
|
|
("", ""), |
|
("/", "/"), |
|
("//", "//"), |
|
("///", "///"), |
|
|
|
("path/to", "path/to"), |
|
("././path/to", "path/to"), |
|
("path/./to", "path/to"), |
|
("path/././to", "path/to"), |
|
("path/to/.", "path/to/"), |
|
("path/to/./.", "path/to/"), |
|
|
|
("../path/to", "path/to"), |
|
("path/../to", "to"), |
|
("path/../../to", "to"), |
|
|
|
|
|
("/foo/../../../ton", "/ton"), |
|
("/foo/../../../..bar", "/..bar"), |
|
|
|
("μονοπάτι/../../να/ᴜɴɪ/ᴄᴏᴅᴇ", "να/ᴜɴɪ/ᴄᴏᴅᴇ"), |
|
("μονοπάτι/../../να/𝕦𝕟𝕚/𝕔𝕠𝕕𝕖/.", "να/𝕦𝕟𝕚/𝕔𝕠𝕕𝕖/"), |
|
] |
|
|
|
|
|
@pytest.mark.parametrize("original,expected", PATHS) |
|
def test__normalize_path(original, expected): |
|
assert URL._normalize_path(original) == expected |
|
|