Buckets:

download
raw
1.07 kB
import pytest
from pydantic import TypeAdapter, ValidationError
from tiled.type_aliases import EntryPointString
type_adapter = TypeAdapter(EntryPointString)
@pytest.mark.parametrize(
("s", "args"),
[
# callables and valid arguments for them
("json:dumps", ({"a": 1},)), # function in package
("os.path:join", ("a", "b")), # function in submodule
("datetime:datetime.now", ()), # method
],
)
def test_valid_input(s, args):
result = type_adapter.validate_python(s)
# Verify that we have the real method by calling it.
result(*args)
@pytest.mark.parametrize(
"s",
[
"", # empty
":", # empty parts
"nonexistent:module", # bad module
"os:nonexistent", # bad attribute
"os.path:nonexistent.method", # bad nested attribute
"os.path.join", # dotted syntax (not allowed)
"datetime.datetime.now", # dotted syntax (not allowed)
],
)
def test_invalid_input(s):
with pytest.raises(ValidationError):
type_adapter.validate_python(s)

Xet Storage Details

Size:
1.07 kB
·
Xet hash:
2bd48fc97a40bccc37e0ee1fdc31d155a30da0ba827573d951565d5d00392141

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.