MCPcopy
hub / github.com/django/django / format

Method format

django/test/runner.py:45–63  ·  view source on GitHub ↗
(self, record)

Source from the content-addressed store, hash-verified

43
44class QueryFormatter(logging.Formatter):
45 def format(self, record):
46 if (alias := getattr(record, "alias", None)) in connections:
47 format_sql = connections[alias].ops.format_debug_sql
48
49 sql = None
50 formatted_sql = None
51 if args := record.args:
52 if isinstance(args, tuple) and len(args) > 1 and (sql := args[1]):
53 record.args = (args[0], formatted_sql := format_sql(sql), *args[2:])
54 elif isinstance(record.args, dict) and (sql := record.args.get("sql")):
55 record.args["sql"] = formatted_sql = format_sql(sql)
56
57 if extra_sql := getattr(record, "sql", None):
58 if extra_sql == sql:
59 record.sql = formatted_sql
60 else:
61 record.sql = format_sql(extra_sql)
62
63 return super().format(record)
64
65
66class DebugSQLTextTestResult(unittest.TextTestResult):

Callers 12

check_picklableMethod · 0.45
_hash_itemMethod · 0.45
shuffleMethod · 0.45
__init_subclass__Method · 0.45
renderMethod · 0.45
do_ifFunction · 0.45
templatesMethod · 0.45
__getitem__Method · 0.45
__init__Method · 0.45
app_dirnameMethod · 0.45
__init__Method · 0.45

Calls 1

getMethod · 0.45

Tested by 1

__init_subclass__Method · 0.36