| 1 |
import os |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
|
| 6 |
def _require_extension() -> bool: |
| 7 |
"""Check if REQUIRE_EXTENSION or REQUIRE_CYTHON is truthy.""" |
| 8 |
for key in ("REQUIRE_EXTENSION", "REQUIRE_CYTHON"): |
| 9 |
if os.environ.get(key, "").lower() in ("1", "true", "yes"): |
| 10 |
return True |
| 11 |
return False |
| 12 |
|
| 13 |
|
| 14 |
def test_require_c_extension(): |
| 15 |
"""Fail if REQUIRE_EXTENSION is set and the C extension module is not available.""" |
| 16 |
if not _require_extension(): |
| 17 |
pytest.skip("REQUIRE_EXTENSION is not truthy") |
| 18 |
import ulid_transform._ulid_impl as c_impl |
| 19 |
|
| 20 |
assert repr(c_impl.ulid_now).startswith("<built-in function") |