ashb commented on a change in pull request #14865:
URL: https://github.com/apache/airflow/pull/14865#discussion_r596703238



##########
File path: tests/www/test_app.py
##########
@@ -241,9 +242,13 @@ def test_correct_default_is_set_for_cookie_samesite(self):
         assert app.config['SESSION_COOKIE_SAMESITE'] == 'Lax'
 
 
-class TestFlaskCli(unittest.TestCase):
-    @dont_initialize_flask_app_submodules
-    def test_flask_cli_should_display_routes(self):
-        with mock.patch.dict("os.environ", 
FLASK_APP="airflow.www.app:create_app"):
-            output = subprocess.check_output(["flask", "routes"])
-            assert "/api/v1/version" in output.decode()
+class TestFlaskCli:
+    @dont_initialize_flask_app_submodules(skip_all_except=['init_appbuilder'])
+    def test_flask_cli_should_display_routes(self, capsys):
+        with mock.patch.dict("os.environ", 
FLASK_APP="airflow.www.app:cached_app"), mock.patch.object(
+            sys, 'argv', ['flask', 'routes']
+        ), pytest.raises(SystemExit):
+            runpy.run_module('flask', run_name='__main__')
+
+        output = capsys.readouterr()
+        assert "/login/" in output.out

Review comment:
       Me too - I felt there had to be a better way of doing it than my first 
hacky solution (`from flask.cli import cli; cli.main()`) which felt too tied in 
to the implementation detail of flask
   
   This is much more "stable"




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to