diff --git a/packages/fastuuid/meta.yaml b/packages/fastuuid/meta.yaml new file mode 100644 index 00000000..a7347cb6 --- /dev/null +++ b/packages/fastuuid/meta.yaml @@ -0,0 +1,16 @@ +package: + name: fastuuid + version: 0.14.0 + top-level: + - fastuuid +source: + url: https://files.pythonhosted.org/packages/source/f/fastuuid/fastuuid-0.14.0.tar.gz + sha256: 178947fc2f995b38497a74172adee64fdeb8b7ec18f2a5934d037641ba265d26 +about: + home: null + PyPI: https://pypi.org/project/fastuuid + summary: Python bindings to Rust's UUID library. + license: null +extra: + recipe-maintainers: + - PUT_YOUR_GITHUB_USERNAME_HERE diff --git a/packages/fastuuid/test_fastuuid.py b/packages/fastuuid/test_fastuuid.py new file mode 100644 index 00000000..8ce60512 --- /dev/null +++ b/packages/fastuuid/test_fastuuid.py @@ -0,0 +1,64 @@ +from pytest_pyodide import run_in_pyodide + + +@run_in_pyodide(packages=["fastuuid"]) +def test_fastuuid(selenium): + import pytest + from fastuuid import UUID, uuid1, uuid3, uuid4, uuid5, uuid7, uuid_v1mc + import re + import uuid + UUID_REGEX = re.compile("[0-F]{8}-([0-F]{4}-){3}[0-F]{12}", re.I) + + + with pytest.raises( + TypeError, + match="one of the hex, bytes, bytes_le, fields, or int arguments must be given", + ): + UUID() + + expected = uuid4() + actual = UUID(str(expected)) + other = uuid4() + + assert expected == actual + assert expected != other + a = UUID(int=10) + b = UUID(int=20) + c = UUID(int=20) + + assert a < b + assert b > a + assert a <= b + assert b >= a + assert c <= c + assert c >= c + + expected = uuid_v1mc() + assert expected.version == 1 + assert expected.variant == "specified in RFC 4122" + assert UUID_REGEX.match(str(expected)) + assert str(expected) == str(uuid.UUID(str(expected))) + + expected = uuid3(uuid4(), b"foo") + assert expected.version == 3 + assert expected.variant == "specified in RFC 4122" + assert UUID_REGEX.match(str(expected)) + assert str(expected) == str(uuid.UUID(str(expected))) + + expected = uuid4() + assert expected.version == 4 + assert expected.variant == "specified in RFC 4122" + assert UUID_REGEX.match(str(expected)) + assert str(expected) == str(uuid.UUID(str(expected))) + + expected = uuid5(uuid4(), b"foo") + assert expected.version == 5 + assert expected.variant == "specified in RFC 4122" + assert UUID_REGEX.match(str(expected)) + assert str(expected) == str(uuid.UUID(str(expected))) + + expected = uuid7() + assert expected.version == 7 + assert expected.variant == "specified in RFC 4122" + assert UUID_REGEX.match(str(expected)) + assert str(expected) == str(uuid.UUID(str(expected)))