File: test_ulid_strings.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 (38 lines) | stat: -rw-r--r-- 1,182 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
30
31
32
33
34
35
36
37
38
import pytest
import tests.conftest  # noqa


@pytest.mark.benchmark(group="ulid_strings")
def test_ut_ulid_now(benchmark, impl):
    assert isinstance(benchmark(lambda: impl.ulid_now()), str)


@pytest.mark.benchmark(group="ulid_strings")
def test_ut_ulid_at_time(benchmark, impl):
    assert isinstance(benchmark(lambda: impl.ulid_at_time(1)), str)


@pytest.mark.benchmark(group="ulid_strings")
def test_ulid2_ulid_now(benchmark):
    ulid2 = pytest.importorskip("ulid2")
    assert isinstance(benchmark(lambda: ulid2.generate_ulid_as_base32()), str)


@pytest.mark.benchmark(group="ulid_strings")
def test_ulid2_ulid_at_time(benchmark):
    ulid2 = pytest.importorskip("ulid2")
    assert isinstance(
        benchmark(lambda: ulid2.generate_ulid_as_base32(timestamp=1)), str
    )


@pytest.mark.benchmark(group="ulid_strings")
def test_ulidpy_uuid_now(benchmark):
    ulid = pytest.importorskip("ulid")
    assert isinstance(benchmark(lambda: ulid.new().str), str)


@pytest.mark.benchmark(group="ulid_strings")
def test_ulidpy_uuid_at_time(benchmark):
    ulid = pytest.importorskip("ulid")
    assert isinstance(benchmark(lambda: ulid.from_timestamp(timestamp=1).str), str)