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

cle-b / httpdbg / 15096721848

18 May 2025 02:04PM UTC coverage: 88.45% (+0.1%) from 88.306%
15096721848

push

github

web-flow
hook function for custom initiator only if imported (#192)

39 of 43 new or added lines in 4 files covered. (90.7%)

2060 of 2329 relevant lines covered (88.45%)

0.88 hits per line

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

96.43
/httpdbg/hooks/utils.py
1
# -*- coding: utf-8 -*-
2
from collections.abc import Callable
1✔
3
import inspect
1✔
4
import typing
1✔
5

6
from httpdbg.log import logger
1✔
7

8
if typing.TYPE_CHECKING:
1✔
NEW
9
    from httpdbg.records import HTTPRecords
×
10

11

12
def getcallargs(original_method, *args, **kwargs):
1✔
13
    while hasattr(
1✔
14
        original_method, "__httpdbg__"
15
    ):  # to retrieve the original method in case of nested hooks
16
        original_method = original_method.__httpdbg__
1✔
17

18
    try:
1✔
19
        callargs = (
1✔
20
            inspect.signature(original_method).bind_partial(*args, **kwargs).arguments
21
        )
22
    except Exception as ex:
1✔
23
        logger().debug(f"getcallargs - exception {str(ex)}")
1✔
24
        # TypeError('too many positional arguments') may occur when using pytest (seems related to teardown_method)
25
        callargs = {}
1✔
26
        i = 0
1✔
27
        for arg in args:
1✔
28
            i += 1
1✔
29
            callargs[f"_positional_argument{i}"] = arg
1✔
30

31
    callargs.update(kwargs)
1✔
32
    logger().info(f"getcallargs {original_method} - {[arg for arg in callargs]}")
1✔
33
    return callargs
1✔
34

35

36
def decorate(records: "HTTPRecords", method: Callable, hook: Callable):
1✔
37
    ori = method
1✔
38
    method = hook(records, method)
1✔
39
    method.__httpdbg__ = ori  # type: ignore[attr-defined]
1✔
40
    return method
1✔
41

42

43
def undecorate(method: Callable):
1✔
44
    return method.__httpdbg__  # type: ignore[attr-defined]
1✔
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