Cleanup typing
This commit is contained in:
@@ -349,11 +349,11 @@ def test_get_app_does_not_exist():
|
||||
with pytest.raises(
|
||||
SanicException,
|
||||
match="Sanic app name 'does-not-exist' not found.\n"
|
||||
"App instantiation must occur outside "
|
||||
"if __name__ == '__main__' "
|
||||
"block or by using an AppLoader.\nSee "
|
||||
"https://sanic.dev/en/guide/deployment/app-loader.html"
|
||||
" for more details."
|
||||
"App instantiation must occur outside "
|
||||
"if __name__ == '__main__' "
|
||||
"block or by using an AppLoader.\nSee "
|
||||
"https://sanic.dev/en/guide/deployment/app-loader.html"
|
||||
" for more details.",
|
||||
):
|
||||
Sanic.get_app("does-not-exist")
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from pytest import MonkeyPatch
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.config import DEFAULT_CONFIG, Config
|
||||
from sanic.constants import LocalCertCreator
|
||||
from sanic.constants import LocalCertCreator, RestartOrder
|
||||
from sanic.exceptions import PyFileError
|
||||
|
||||
|
||||
@@ -436,3 +436,19 @@ def test_convert_local_cert_creator(passed, expected):
|
||||
app = Sanic("Test")
|
||||
assert app.config.LOCAL_CERT_CREATOR is expected
|
||||
del os.environ["SANIC_LOCAL_CERT_CREATOR"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"passed,expected",
|
||||
(
|
||||
("shutdown_first", RestartOrder.SHUTDOWN_FIRST),
|
||||
("startup_first", RestartOrder.STARTUP_FIRST),
|
||||
("SHUTDOWN_FIRST", RestartOrder.SHUTDOWN_FIRST),
|
||||
("STARTUP_FIRST", RestartOrder.STARTUP_FIRST),
|
||||
),
|
||||
)
|
||||
def test_convert_restart_order(passed, expected):
|
||||
os.environ["SANIC_RESTART_ORDER"] = passed
|
||||
app = Sanic("Test")
|
||||
assert app.config.RESTART_ORDER is expected
|
||||
del os.environ["SANIC_RESTART_ORDER"]
|
||||
|
||||
@@ -10,8 +10,7 @@ import pytest
|
||||
import sanic
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.log import Colors
|
||||
from sanic.log import LOGGING_CONFIG_DEFAULTS, logger
|
||||
from sanic.log import LOGGING_CONFIG_DEFAULTS, Colors, logger
|
||||
from sanic.response import text
|
||||
|
||||
|
||||
@@ -254,11 +253,11 @@ def test_verbosity(app, caplog, app_verbosity, log_verbosity, exists):
|
||||
|
||||
|
||||
def test_colors_enum_format():
|
||||
assert f'{Colors.END}' == Colors.END.value
|
||||
assert f'{Colors.BOLD}' == Colors.BOLD.value
|
||||
assert f'{Colors.BLUE}' == Colors.BLUE.value
|
||||
assert f'{Colors.GREEN}' == Colors.GREEN.value
|
||||
assert f'{Colors.PURPLE}' == Colors.PURPLE.value
|
||||
assert f'{Colors.RED}' == Colors.RED.value
|
||||
assert f'{Colors.SANIC}' == Colors.SANIC.value
|
||||
assert f'{Colors.YELLOW}' == Colors.YELLOW.value
|
||||
assert f"{Colors.END}" == Colors.END.value
|
||||
assert f"{Colors.BOLD}" == Colors.BOLD.value
|
||||
assert f"{Colors.BLUE}" == Colors.BLUE.value
|
||||
assert f"{Colors.GREEN}" == Colors.GREEN.value
|
||||
assert f"{Colors.PURPLE}" == Colors.PURPLE.value
|
||||
assert f"{Colors.RED}" == Colors.RED.value
|
||||
assert f"{Colors.SANIC}" == Colors.SANIC.value
|
||||
assert f"{Colors.YELLOW}" == Colors.YELLOW.value
|
||||
|
||||
Reference in New Issue
Block a user