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 36 37 38 39 40 41
|
import pytest
from cyclopts import ValidationError
from cyclopts.types import URL, Email
def test_types_web_email(convert):
convert(Email, "foo@bar.com")
def test_types_web_email_invalid(convert):
with pytest.raises(ValidationError):
convert(Email, "foo")
@pytest.mark.parametrize(
"url",
[
"google.com",
"www.google.com",
"http://www.google.com",
"https://www.google.com",
"https://www.google.com:443",
"https://www.google.com/foo/bar",
],
)
def test_types_url(convert, url):
convert(URL, url)
@pytest.mark.parametrize(
"url",
[
"foo",
"bar.",
"foo bar.com",
],
)
def test_types_url_invalid(convert, url):
with pytest.raises(ValidationError):
convert(URL, url)
|