(test_apps, monkeypatch)
| 245 | |
| 246 | |
| 247 | def test_scriptinfo(test_apps, monkeypatch): |
| 248 | obj = ScriptInfo(app_import_path="cliapp.app:testapp") |
| 249 | app = obj.load_app() |
| 250 | assert app.name == "testapp" |
| 251 | assert obj.load_app() is app |
| 252 | |
| 253 | # import app with module's absolute path |
| 254 | cli_app_path = str(test_path / "cliapp" / "app.py") |
| 255 | |
| 256 | obj = ScriptInfo(app_import_path=cli_app_path) |
| 257 | app = obj.load_app() |
| 258 | assert app.name == "testapp" |
| 259 | assert obj.load_app() is app |
| 260 | obj = ScriptInfo(app_import_path=f"{cli_app_path}:testapp") |
| 261 | app = obj.load_app() |
| 262 | assert app.name == "testapp" |
| 263 | assert obj.load_app() is app |
| 264 | |
| 265 | def create_app(): |
| 266 | return Flask("createapp") |
| 267 | |
| 268 | obj = ScriptInfo(create_app=create_app) |
| 269 | app = obj.load_app() |
| 270 | assert app.name == "createapp" |
| 271 | assert obj.load_app() is app |
| 272 | |
| 273 | obj = ScriptInfo() |
| 274 | pytest.raises(NoAppException, obj.load_app) |
| 275 | |
| 276 | # import app from wsgi.py in current directory |
| 277 | monkeypatch.chdir(test_path / "helloworld") |
| 278 | obj = ScriptInfo() |
| 279 | app = obj.load_app() |
| 280 | assert app.name == "hello" |
| 281 | |
| 282 | # import app from app.py in current directory |
| 283 | monkeypatch.chdir(test_path / "cliapp") |
| 284 | obj = ScriptInfo() |
| 285 | app = obj.load_app() |
| 286 | assert app.name == "testapp" |
| 287 | |
| 288 | |
| 289 | def test_app_cli_has_app_context(app, runner): |
nothing calls this directly
no test coverage detected
searching dependent graphs…