Compare commits
5 Commits
main
...
motd-fixes
Author | SHA1 | Date | |
---|---|---|---|
|
44bf7ba79a | ||
|
9e7ca10c52 | ||
|
fe32f4eb74 | ||
|
ebe29d3d26 | ||
|
f651f7436f |
|
@ -73,6 +73,14 @@ class MOTDTTY(MOTD):
|
|||
self.value_width = min(
|
||||
max(map(len, self.data.values())), self.max_value_width
|
||||
)
|
||||
if self.extra:
|
||||
self.key_width = max(
|
||||
self.key_width, max(map(len, self.extra.keys()))
|
||||
)
|
||||
self.value_width = min(
|
||||
max((*map(len, self.extra.values()), self.value_width)),
|
||||
self.max_value_width,
|
||||
)
|
||||
self.logo_lines = self.logo.split("\n") if self.logo else []
|
||||
self.logo_line_length = 24
|
||||
self.centering_length = (
|
||||
|
@ -104,7 +112,7 @@ class MOTDTTY(MOTD):
|
|||
self._render_data(lines, self.data, 0)
|
||||
if self.extra:
|
||||
logo_part = self._get_logo_part(len(lines) - 4)
|
||||
lines.append(f"| {logo_part} ├{display_filler}┤")
|
||||
lines.append(f"│ {logo_part} ├{display_filler}┤")
|
||||
self._render_data(lines, self.extra, len(lines) - 4)
|
||||
|
||||
self._render_fill(lines)
|
||||
|
|
|
@ -90,6 +90,7 @@ else: # no cov
|
|||
class StartupMixin(metaclass=SanicMeta):
|
||||
_app_registry: ClassVar[Dict[str, Sanic]]
|
||||
|
||||
name: str
|
||||
config: Config
|
||||
listeners: Dict[str, List[ListenerType[Any]]]
|
||||
state: ApplicationState
|
||||
|
@ -605,6 +606,7 @@ class StartupMixin(metaclass=SanicMeta):
|
|||
server = "ASGI" if self.asgi else "unknown" # type: ignore
|
||||
|
||||
display = {
|
||||
"app": self.name,
|
||||
"mode": " ".join(mode),
|
||||
"server": server,
|
||||
"python": platform.python_version(),
|
||||
|
|
|
@ -31,10 +31,11 @@ def test_motd_with_expected_info(app, run_startup):
|
|||
logs = run_startup(app)
|
||||
|
||||
assert logs[1][2] == f"Sanic v{__version__}"
|
||||
assert logs[3][2] == "mode: debug, single worker"
|
||||
assert logs[4][2] == "server: sanic, HTTP/1.1"
|
||||
assert logs[5][2] == f"python: {platform.python_version()}"
|
||||
assert logs[6][2] == f"platform: {platform.platform()}"
|
||||
assert logs[3][2] == "app: test_motd_with_expected_info"
|
||||
assert logs[4][2] == "mode: debug, single worker"
|
||||
assert logs[5][2] == "server: sanic, HTTP/1.1"
|
||||
assert logs[6][2] == f"python: {platform.python_version()}"
|
||||
assert logs[7][2] == f"platform: {platform.platform()}"
|
||||
|
||||
|
||||
def test_motd_init():
|
||||
|
@ -61,7 +62,7 @@ def test_motd_display(caplog):
|
|||
│ │
|
||||
├───────────────────────┬────────┤
|
||||
│ foobar │ one: 1 │
|
||||
| ├────────┤
|
||||
│ ├────────┤
|
||||
│ │ two: 2 │
|
||||
└───────────────────────┴────────┘
|
||||
"""
|
||||
|
|
|
@ -517,7 +517,7 @@ def test_stack_trace_on_not_found(app, static_file_directory, caplog):
|
|||
counter = Counter([(r[0], r[1]) for r in caplog.record_tuples])
|
||||
|
||||
assert response.status == 404
|
||||
assert counter[("sanic.root", logging.INFO)] == 9
|
||||
assert counter[("sanic.root", logging.INFO)] == 10
|
||||
assert counter[("sanic.root", logging.ERROR)] == 0
|
||||
assert counter[("sanic.error", logging.ERROR)] == 0
|
||||
assert counter[("sanic.server", logging.INFO)] == 2
|
||||
|
@ -536,7 +536,7 @@ def test_no_stack_trace_on_not_found(app, static_file_directory, caplog):
|
|||
counter = Counter([(r[0], r[1]) for r in caplog.record_tuples])
|
||||
|
||||
assert response.status == 404
|
||||
assert counter[("sanic.root", logging.INFO)] == 9
|
||||
assert counter[("sanic.root", logging.INFO)] == 10
|
||||
assert counter[("sanic.root", logging.ERROR)] == 0
|
||||
assert counter[("sanic.error", logging.ERROR)] == 0
|
||||
assert counter[("sanic.server", logging.INFO)] == 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user