Changes to CLI (#2401)

Co-authored-by: Callum Fleming <howzitcal@zohomail.com>
Co-authored-by: Adam Hopkins <adam@amhopkins.com>
This commit is contained in:
Callum
2022-03-23 10:30:41 +02:00
committed by GitHub
parent 2a8e91052f
commit 44b108b564
3 changed files with 40 additions and 1 deletions

6
tests/fake/factory.py Normal file
View File

@@ -0,0 +1,6 @@
from sanic import Sanic
def run():
app = Sanic("FactoryTest")
return app

View File

@@ -57,6 +57,22 @@ def test_server_run(appname):
assert firstline == b"Goin' Fast @ http://127.0.0.1:8000"
def test_error_with_function_as_instance_without_factory_arg():
command = ["sanic", "fake.factory.run"]
out, err, exitcode = capture(command)
assert b"try: \nsanic fake.factory.run --factory" in err
assert exitcode != 1
def test_error_with_path_as_instance_without_simple_arg():
command = ["sanic", "./fake/"]
out, err, exitcode = capture(command)
assert (
b"Please use --simple if you are passing a directory to sanic." in err
)
assert exitcode != 1
@pytest.mark.parametrize(
"cmd",
(