Skip to content

Commit 4a9ef54

Browse files
committed
chore: add test case
1 parent d36b6da commit 4a9ef54

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_cli.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sanic import __version__
1414
from sanic.__main__ import main
1515
from sanic.cli.inspector_client import InspectorClient
16+
from sanic.models.ctx_types import REPLLocal
1617

1718
from .conftest import get_port
1819

@@ -404,3 +405,25 @@ def test_command_with_renamed_command(caplog):
404405
with patch("sys.argv", ["sanic", *args]):
405406
lines = capture(args, caplog)
406407
assert "BAZ" in lines
408+
409+
410+
def test_add_local_method(app):
411+
def foo(): ...
412+
def bar():
413+
"""bar method docstring."""
414+
415+
class Luffy: ...
416+
417+
import os
418+
419+
app.repl_ctx.add(foo)
420+
app.repl_ctx.add(bar)
421+
app.repl_ctx.add(Luffy)
422+
app.repl_ctx.add(os, desc="Standard os module.")
423+
424+
assert REPLLocal(foo, "foo", "") in app.repl_ctx._locals
425+
assert (
426+
REPLLocal(bar, "bar", "bar method docstring.") in app.repl_ctx._locals
427+
)
428+
assert REPLLocal(Luffy, "Luffy", "") in app.repl_ctx._locals
429+
assert REPLLocal(os, "os", "Standard os module.") in app.repl_ctx._locals

0 commit comments

Comments
 (0)