• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mindflayer / python-mocket / 14082486712

26 Mar 2025 11:46AM UTC coverage: 98.592% (-0.1%) from 98.688%
14082486712

Pull #283

github

web-flow
Merge 80e5eba05 into 1722f05ef
Pull Request #283: Missing dependency

7 of 8 new or added lines in 4 files covered. (87.5%)

3 existing lines in 2 files now uncovered.

980 of 994 relevant lines covered (98.59%)

6.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/mocket/utils.py
1
from __future__ import annotations
7✔
2

3
import binascii
7✔
4
import contextlib
7✔
5
from typing import Callable
7✔
6

7
import decorator
7✔
8

9
from mocket.compat import decode_from_bytes, encode_to_bytes
7✔
10

11

12
def hexdump(binary_string: bytes) -> str:
7✔
13
    r"""
14
    >>> hexdump(b"bar foobar foo") == decode_from_bytes(encode_to_bytes("62 61 72 20 66 6F 6F 62 61 72 20 66 6F 6F"))
15
    True
16
    """
17
    bs = decode_from_bytes(binascii.hexlify(binary_string).upper())
7✔
18
    return " ".join(a + b for a, b in zip(bs[::2], bs[1::2]))
7✔
19

20

21
def hexload(string: str) -> bytes:
7✔
22
    r"""
23
    >>> hexload("62 61 72 20 66 6F 6F 62 61 72 20 66 6F 6F") == encode_to_bytes("bar foobar foo")
24
    True
25
    """
26
    string_no_spaces = "".join(string.split())
7✔
27
    try:
7✔
28
        return encode_to_bytes(binascii.unhexlify(string_no_spaces))
7✔
29
    except binascii.Error as e:
7✔
30
        raise ValueError from e
7✔
31

32

33
def get_mocketize(wrapper_: Callable) -> Callable:
7✔
34
    # trying to support different versions of `decorator`
35
    with contextlib.suppress(TypeError):
7✔
36
        return decorator.decorator(wrapper_, kwsyntax=True)  # type: ignore[call-arg,unused-ignore]
7✔
NEW
37
    return decorator.decorator(wrapper_)
×
38

39

40
__all__ = (
7✔
41
    "get_mocketize",
42
    "hexdump",
43
    "hexload",
44
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc