-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(masonry): add tests for
escape_*
methods
- Loading branch information
1 parent
3bf7ad0
commit 2f26402
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from poetry.core.masonry.utils.helpers import escape_name | ||
from poetry.core.masonry.utils.helpers import escape_version | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"version,expected", | ||
[ | ||
("1.2.3", "1.2.3"), | ||
("1.2.3_1", "1.2.3_1"), | ||
("1.2.3-1", "1.2.3_1"), | ||
("1.2.3-1", "1.2.3_1"), | ||
("2022.2", "2022.2"), | ||
("12.20.12-----451---14-1-4-41", "12.20.12_451_14_1_4_41"), | ||
("1.0b2.dev1", "1.0b2.dev1"), | ||
("1.0+abc.7", "1.0+abc.7"), | ||
], | ||
) | ||
def test_escape_version(version: str, expected: str) -> None: | ||
assert escape_version(version) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name,expected", | ||
[ | ||
("foo", "foo"), | ||
("foo-bar", "foo_bar"), | ||
("FOO-bAr", "FOO_bAr"), | ||
("foo.bar", "foo.bar"), | ||
("foo123-ba---.r", "foo123_ba_.r"), | ||
], | ||
) | ||
def test_escape_name(name: str, expected: str) -> None: | ||
assert escape_name(name) == expected |