Skip to content

Commit

Permalink
chore: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
goodki-d committed Jan 9, 2025
1 parent d36b6da commit 4a9ef54
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from sanic import __version__
from sanic.__main__ import main
from sanic.cli.inspector_client import InspectorClient
from sanic.models.ctx_types import REPLLocal

from .conftest import get_port

Expand Down Expand Up @@ -404,3 +405,25 @@ def test_command_with_renamed_command(caplog):
with patch("sys.argv", ["sanic", *args]):
lines = capture(args, caplog)
assert "BAZ" in lines


def test_add_local_method(app):
def foo(): ...
def bar():
"""bar method docstring."""

class Luffy: ...

import os

app.repl_ctx.add(foo)
app.repl_ctx.add(bar)
app.repl_ctx.add(Luffy)
app.repl_ctx.add(os, desc="Standard os module.")

assert REPLLocal(foo, "foo", "") in app.repl_ctx._locals
assert (
REPLLocal(bar, "bar", "bar method docstring.") in app.repl_ctx._locals
)
assert REPLLocal(Luffy, "Luffy", "") in app.repl_ctx._locals
assert REPLLocal(os, "os", "Standard os module.") in app.repl_ctx._locals

0 comments on commit 4a9ef54

Please sign in to comment.