File: test_is_0x_prefixed.py

package info (click to toggle)
python-eth-utils 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 5,985; makefile: 238
file content (19 lines) | stat: -rw-r--r-- 487 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pytest

from eth_utils.hexadecimal import (
    is_0x_prefixed,
)


@pytest.mark.parametrize(
    "value,expected",
    (("", False), ("0x", True), ("0x12345", True), ("12345", False), ("0X12345", True)),
)
def test_is_0x_prefixed(value, expected):
    assert is_0x_prefixed(value) is expected


@pytest.mark.parametrize("value", (b"", 123, {}, lambda: None))
def test_is_0x_prefixed_rejects_non_text_types(value):
    with pytest.raises(TypeError):
        is_0x_prefixed(value)