File: test_ulid_as_uuid.py

package info (click to toggle)
python-ulid-transform 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: cpp: 942; python: 695; sh: 5; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 805 bytes parent folder | download
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
from uuid import UUID

import pytest
import tests.conftest  # noqa


@pytest.mark.benchmark(group="ulid_as_uuid")
def test_ut_ulid_now_bytes(benchmark, impl):
    assert isinstance(
        benchmark(lambda: UUID(bytes=impl.ulid_now_bytes())),
        UUID,
    )


@pytest.mark.benchmark(group="ulid_as_uuid")
def test_ut_ulid_hex(benchmark, impl):
    assert isinstance(benchmark(lambda: UUID(hex=impl.ulid_hex())), UUID)


@pytest.mark.benchmark(group="ulid_as_uuid")
def test_ulid2_uuid(benchmark):
    ulid2 = pytest.importorskip("ulid2")
    assert isinstance(benchmark(lambda: ulid2.generate_ulid_as_uuid()), UUID)


@pytest.mark.benchmark(group="ulid_as_uuid")
def test_ulidpy_uuid(benchmark):
    ulid = pytest.importorskip("ulid")
    assert isinstance(benchmark(lambda: ulid.new().uuid), UUID)