Function called before API call Emit a debug message describing the API name and arguments @param api_name: name of the API @param api_args: tuple containing the API arguments
(self, api_name, api_args)
| 93 | self.logger = test.logger |
| 94 | |
| 95 | def before_api(self, api_name, api_args): |
| 96 | """ |
| 97 | Function called before API call |
| 98 | Emit a debug message describing the API name and arguments |
| 99 | |
| 100 | @param api_name: name of the API |
| 101 | @param api_args: tuple containing the API arguments |
| 102 | """ |
| 103 | |
| 104 | def _friendly_format(val): |
| 105 | if not isinstance(val, str): |
| 106 | return val |
| 107 | if len(val) == 6: |
| 108 | return "{!s} ({!s})".format( |
| 109 | val, ":".join(["{:02x}".format(scapy.compat.orb(x)) for x in val]) |
| 110 | ) |
| 111 | try: |
| 112 | # we don't call test_type(val) because it is a packed value. |
| 113 | return "{!s} ({!s})".format(val, str(ipaddress.ip_address(val))) |
| 114 | except ValueError: |
| 115 | return val |
| 116 | |
| 117 | _args = ", ".join( |
| 118 | "{!s}={!r}".format(key, _friendly_format(val)) |
| 119 | for (key, val) in api_args.items() |
| 120 | ) |
| 121 | self.logger.debug("API: %s (%s)" % (api_name, _args), extra={"color": RED}) |
| 122 | |
| 123 | def after_api(self, api_name, api_args): |
| 124 | """ |
no test coverage detected