File: utils.py

package info (click to toggle)
python-ulid-transform 1.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 360 kB
  • sloc: python: 695; cpp: 476; sh: 5; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 766 bytes parent folder | download | duplicates (2)
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
from __future__ import annotations

import logging

import pytest

log = logging.getLogger(__name__)


def _get_available_implementations():
    import ulid_transform._py_ulid_impl as ulid_transform_py

    yield ("python", ulid_transform_py)

    try:
        import ulid_transform._ulid_impl as ulid_transform_c

        yield ("c", ulid_transform_c)
    except ImportError:
        log.warning("Failed to import C extension", exc_info=True)
        pass


_impls = dict(_get_available_implementations())
impl_names, impl_modules = zip(*_impls.items(), strict=False)


@pytest.fixture(params=impl_modules, ids=impl_names)
def impl(request):
    """Fixture that cycles through all available implementations of the ulid_transform module."""
    return request.param