ソースを参照

fix: patch the sys.argv when run GUI service

trgiangdo 1 年間 前
コミット
6544ff37fe
39 ファイル変更190 行追加85 行削除
  1. 3 0
      tests/cli/test_cli.py
  2. 3 1
      tests/gui/actions/test_download.py
  3. 3 1
      tests/gui/actions/test_get_state_id.py
  4. 3 1
      tests/gui/actions/test_hold_control.py
  5. 3 1
      tests/gui/actions/test_invoke_callback.py
  6. 3 1
      tests/gui/actions/test_navigate.py
  7. 3 1
      tests/gui/actions/test_notify.py
  8. 3 1
      tests/gui/actions/test_resume_control.py
  9. 8 4
      tests/gui/config/test_cli.py
  10. 3 1
      tests/gui/data/test_pandas_data_accessor.py
  11. 3 1
      tests/gui/gui_specific/test_folder_pages_binding.py
  12. 15 7
      tests/gui/gui_specific/test_gui.py
  13. 4 1
      tests/gui/gui_specific/test_locals_context.py
  14. 9 4
      tests/gui/gui_specific/test_navigate.py
  15. 5 2
      tests/gui/gui_specific/test_partial.py
  16. 3 1
      tests/gui/gui_specific/test_render_route.py
  17. 5 2
      tests/gui/gui_specific/test_run_thread.py
  18. 3 1
      tests/gui/gui_specific/test_state.py
  19. 8 3
      tests/gui/gui_specific/test_variable_binding.py
  20. 7 5
      tests/gui/helpers.py
  21. 3 3
      tests/gui/ignore/no_file/test_ignore.py
  22. 5 4
      tests/gui/ignore/with_file/test_with_ignore.py
  23. 3 3
      tests/gui/long_runnig/test_long_running.py
  24. 3 1
      tests/gui/renderers/test_html_parsing.py
  25. 5 2
      tests/gui/server/http/test_extension.py
  26. 13 6
      tests/gui/server/http/test_file_upload.py
  27. 5 4
      tests/gui/server/http/test_image_path.py
  28. 7 4
      tests/gui/server/http/test_status.py
  29. 7 3
      tests/gui/server/http/test_user_content.py
  30. 3 1
      tests/gui/server/ws/test_a.py
  31. 3 1
      tests/gui/server/ws/test_broadcast.py
  32. 3 1
      tests/gui/server/ws/test_df.py
  33. 3 1
      tests/gui/server/ws/test_du.py
  34. 5 2
      tests/gui/server/ws/test_on_change.py
  35. 3 1
      tests/gui/server/ws/test_ru.py
  36. 3 1
      tests/gui/server/ws/test_u.py
  37. 3 1
      tests/gui/server/ws/test_with.py
  38. 13 6
      tests/gui/utils/test_evaluator.py
  39. 3 1
      tests/gui/utils/test_map_dict.py

+ 3 - 0
tests/cli/test_cli.py

@@ -47,6 +47,9 @@ def clean_argparser():
 
 
     yield
     yield
 
 
+    _CLI._subparser_action = None
+    _CLI._sub_taipyparsers = {}
+
 
 
 expected_help = """{run,manage-versions,create,migrate,help} ...
 expected_help = """{run,manage-versions,create,migrate,help} ...
 
 

+ 3 - 1
tests/gui/actions/test_download.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -27,7 +28,8 @@ def test_download(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/actions/test_get_state_id.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -24,7 +25,8 @@ def test_get_state_id(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     cid = helpers.create_scope_and_get_sid(gui)
     cid = helpers.create_scope_and_get_sid(gui)
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered

+ 3 - 1
tests/gui/actions/test_hold_control.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -24,7 +25,8 @@ def test_hold_control(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/actions/test_invoke_callback.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -29,7 +30,8 @@ def test_invoke_callback(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>\n<|{val}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>\n<|{val}|>"))
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # client id
     # client id
     cid = helpers.create_scope_and_get_sid(gui)
     cid = helpers.create_scope_and_get_sid(gui)

+ 3 - 1
tests/gui/actions/test_navigate.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -24,7 +25,8 @@ def test_navigate(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/actions/test_notify.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -24,7 +25,8 @@ def test_notify(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/actions/test_resume_control.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -24,7 +25,8 @@ def test_resume_control(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 8 - 4
tests/gui/config/test_cli.py

@@ -74,7 +74,8 @@ def cleanup_test(helpers):
 def test_gui_service_arguments_hierarchy():
 def test_gui_service_arguments_hierarchy():
     # Test default configuration
     # Test default configuration
     gui = Gui()
     gui = Gui()
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     service_config = gui._config.config
     service_config = gui._config.config
     assert not service_config["allow_unsafe_werkzeug"]
     assert not service_config["allow_unsafe_werkzeug"]
     assert service_config["async_mode"] == "gevent"
     assert service_config["async_mode"] == "gevent"
@@ -110,7 +111,8 @@ def test_gui_service_arguments_hierarchy():
 
 
     # Override default configuration by explicit defined arguments in Gui.run()
     # Override default configuration by explicit defined arguments in Gui.run()
     gui = Gui()
     gui = Gui()
-    gui.run(run_server=False, watermark="", host="my_host", port=5001)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, watermark="", host="my_host", port=5001)
     service_config = gui._config.config
     service_config = gui._config.config
     assert service_config["watermark"] == ""
     assert service_config["watermark"] == ""
     assert service_config["host"] == "my_host"
     assert service_config["host"] == "my_host"
@@ -120,7 +122,8 @@ def test_gui_service_arguments_hierarchy():
     # Override Gui.run() arguments by explicit defined arguments in Config.configure_gui()
     # Override Gui.run() arguments by explicit defined arguments in Config.configure_gui()
     Config.configure_gui(dark_mode=False, host="my_2nd_host", port=5002)
     Config.configure_gui(dark_mode=False, host="my_2nd_host", port=5002)
     gui = Gui()
     gui = Gui()
-    gui.run(run_server=False, watermark="", host="my_host", port=5001)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, watermark="", host="my_host", port=5001)
     service_config = gui._config.config
     service_config = gui._config.config
     assert not service_config["dark_mode"]
     assert not service_config["dark_mode"]
     assert service_config["host"] == "my_2nd_host"
     assert service_config["host"] == "my_2nd_host"
@@ -141,7 +144,8 @@ use_reloader = "true:bool"
     )
     )
     Config.load(toml_config.filename)
     Config.load(toml_config.filename)
     gui = Gui()
     gui = Gui()
-    gui.run(run_server=False, host="my_host", port=5001)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, host="my_host", port=5001)
     service_config = gui._config.config
     service_config = gui._config.config
     assert service_config["host"] == "my_3rd_host"
     assert service_config["host"] == "my_3rd_host"
     assert service_config["port"] == 5003
     assert service_config["port"] == 5003

+ 3 - 1
tests/gui/data/test_pandas_data_accessor.py

@@ -12,6 +12,7 @@
 import inspect
 import inspect
 from datetime import datetime
 from datetime import datetime
 from importlib import util
 from importlib import util
+from unittest.mock import patch
 
 
 import pandas  # type: ignore
 import pandas  # type: ignore
 from flask import g
 from flask import g
@@ -211,7 +212,8 @@ def test_decimator(gui: Gui, helpers, small_dataframe):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", "<|Hello {a_decimator}|button|id={btn_id}|>")
     gui.add_page("test", "<|Hello {a_decimator}|button|id={btn_id}|>")
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
 
 
     cid = helpers.create_scope_and_get_sid(gui)
     cid = helpers.create_scope_and_get_sid(gui)

+ 3 - 1
tests/gui/gui_specific/test_folder_pages_binding.py

@@ -12,6 +12,7 @@
 import inspect
 import inspect
 import os
 import os
 from pathlib import Path
 from pathlib import Path
+from unittest.mock import patch
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
@@ -20,6 +21,7 @@ def test_folder_pages_binding(gui: Gui):
     folder_path = f"{Path(Path(__file__).parent.resolve())}{os.path.sep}sample_assets"
     folder_path = f"{Path(Path(__file__).parent.resolve())}{os.path.sep}sample_assets"
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
     gui.add_pages(folder_path)
     gui.add_pages(folder_path)
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     assert len(gui._config.routes) == 3  # 2 files -> 2 routes + 1 default route
     assert len(gui._config.routes) == 3  # 2 files -> 2 routes + 1 default route
     assert len(gui._config.pages) == 3  # 2 files -> 2 pages + 1 default page
     assert len(gui._config.pages) == 3  # 2 files -> 2 pages + 1 default page

+ 15 - 7
tests/gui/gui_specific/test_gui.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import json
 import json
+from unittest.mock import patch
 
 
 import pandas as pd
 import pandas as pd
 import pytest
 import pytest
@@ -24,21 +25,24 @@ def test__get_real_var_name(gui: Gui):
     assert res[0] == ""
     assert res[0] == ""
     assert res[1] == ""
     assert res[1] == ""
 
 
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         with pytest.raises(NameError):
         with pytest.raises(NameError):
             res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
             res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
 
 
 
 
 def test__get_user_instance(gui: Gui):
 def test__get_user_instance(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         with pytest.warns(UserWarning):
         with pytest.warns(UserWarning):
             gui._get_user_instance("", type(None))
             gui._get_user_instance("", type(None))
 
 
 
 
 def test__call_broadcast_callback(gui: Gui):
 def test__call_broadcast_callback(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         res = gui._call_broadcast_callback(lambda s, t: t, ["Hello World"], "mine")
         res = gui._call_broadcast_callback(lambda s, t: t, ["Hello World"], "mine")
         assert res == "Hello World"
         assert res == "Hello World"
@@ -50,7 +54,8 @@ def test__call_broadcast_callback(gui: Gui):
 
 
 
 
 def test__refresh_expr(gui: Gui):
 def test__refresh_expr(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         res = gui._refresh_expr("var", None)
         res = gui._refresh_expr("var", None)
         assert res is None
         assert res is None
@@ -58,7 +63,8 @@ def test__refresh_expr(gui: Gui):
 
 
 def test__tbl_cols(gui: Gui):
 def test__tbl_cols(gui: Gui):
     data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
     data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         res = gui._tbl_cols(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
         res = gui._tbl_cols(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
         d = json.loads(res)
         d = json.loads(res)
@@ -71,7 +77,8 @@ def test__tbl_cols(gui: Gui):
 
 
 def test__chart_conf(gui: Gui):
 def test__chart_conf(gui: Gui):
     data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
     data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         res = gui._chart_conf(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
         res = gui._chart_conf(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
         d = json.loads(res)
         d = json.loads(res)
@@ -87,7 +94,8 @@ def test__chart_conf(gui: Gui):
 
 
 
 
 def test__get_valid_adapter_result(gui: Gui):
 def test__get_valid_adapter_result(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         res = gui._get_valid_adapter_result(("id", "label"))
         res = gui._get_valid_adapter_result(("id", "label"))
         assert isinstance(res, tuple)
         assert isinstance(res, tuple)

+ 4 - 1
tests/gui/gui_specific/test_locals_context.py

@@ -9,6 +9,8 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
+from unittest.mock import patch
+
 import pytest
 import pytest
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
@@ -17,7 +19,8 @@ from taipy.gui.utils._locals_context import _LocalsContext
 
 
 def test_locals_context(gui: Gui):
 def test_locals_context(gui: Gui):
     lc = _LocalsContext()
     lc = _LocalsContext()
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         with pytest.raises(KeyError):
         with pytest.raises(KeyError):
             lc.get_default()
             lc.get_default()

+ 9 - 4
tests/gui/gui_specific/test_navigate.py

@@ -11,6 +11,7 @@
 
 
 import inspect
 import inspect
 import warnings
 import warnings
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown, State, navigate
 from taipy.gui import Gui, Markdown, State, navigate
 
 
@@ -22,7 +23,8 @@ def test_navigate(gui: Gui, helpers):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
         gui.add_page("test", Markdown("#This is a page"))
         gui.add_page("test", Markdown("#This is a page"))
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         # WS client and emit
         # WS client and emit
         ws_client = gui._server._ws.test_client(gui._server.get_flask())
         ws_client = gui._server._ws.test_client(gui._server.get_flask())
@@ -41,7 +43,8 @@ def test_navigate_to_no_route(gui: Gui, helpers):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
         gui.add_page("test", Markdown("#This is a page"))
         gui.add_page("test", Markdown("#This is a page"))
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         # WS client and emit
         # WS client and emit
         ws_client = gui._server._ws.test_client(gui._server.get_flask())
         ws_client = gui._server._ws.test_client(gui._server.get_flask())
@@ -60,7 +63,8 @@ def test_on_navigate_to_inexistant(gui: Gui, helpers):
     with warnings.catch_warnings(record=True) as records:
     with warnings.catch_warnings(record=True) as records:
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
         gui.add_page("test", Markdown("#This is a page"))
         gui.add_page("test", Markdown("#This is a page"))
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         # Get the jsx once so that the page will be evaluated -> variable will be registered
         # Get the jsx once so that the page will be evaluated -> variable will be registered
         sid = helpers.create_scope_and_get_sid(gui)
         sid = helpers.create_scope_and_get_sid(gui)
@@ -79,7 +83,8 @@ def test_on_navigate_to_existant(gui: Gui, helpers):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
         gui.add_page("test1", Markdown("#This is a page test1"))
         gui.add_page("test1", Markdown("#This is a page test1"))
         gui.add_page("test2", Markdown("#This is a page test2"))
         gui.add_page("test2", Markdown("#This is a page test2"))
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         # Get the jsx once so that the page will be evaluated -> variable will be registered
         # Get the jsx once so that the page will be evaluated -> variable will be registered
         sid = helpers.create_scope_and_get_sid(gui)
         sid = helpers.create_scope_and_get_sid(gui)

+ 5 - 2
tests/gui/gui_specific/test_partial.py

@@ -12,6 +12,7 @@
 import json
 import json
 import warnings
 import warnings
 from types import SimpleNamespace
 from types import SimpleNamespace
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 
 
@@ -19,7 +20,8 @@ from taipy.gui import Gui, Markdown
 def test_partial(gui: Gui):
 def test_partial(gui: Gui):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui.add_partial(Markdown("#This is a partial"))
         gui.add_partial(Markdown("#This is a partial"))
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get(f"/taipy-jsx/{gui._config.partial_routes[0]}")
         response = client.get(f"/taipy-jsx/{gui._config.partial_routes[0]}")
         response_data = json.loads(response.get_data().decode("utf-8", "ignore"))
         response_data = json.loads(response.get_data().decode("utf-8", "ignore"))
@@ -30,7 +32,8 @@ def test_partial(gui: Gui):
 def test_partial_update(gui: Gui):
 def test_partial_update(gui: Gui):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         partial = gui.add_partial(Markdown("#This is a partial"))
         partial = gui.add_partial(Markdown("#This is a partial"))
-        gui.run(run_server=False, single_client=True)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False, single_client=True)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get(f"/taipy-jsx/{gui._config.partial_routes[0]}")
         response = client.get(f"/taipy-jsx/{gui._config.partial_routes[0]}")
         response_data = json.loads(response.get_data().decode("utf-8", "ignore"))
         response_data = json.loads(response.get_data().decode("utf-8", "ignore"))

+ 3 - 1
tests/gui/gui_specific/test_render_route.py

@@ -12,6 +12,7 @@
 import inspect
 import inspect
 import json
 import json
 import warnings
 import warnings
+from unittest.mock import patch
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
@@ -20,7 +21,8 @@ def test_render_route(gui: Gui):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
     gui.add_page("page1", "# first page")
     gui.add_page("page1", "# first page")
     gui.add_page("page2", "# second page")
     gui.add_page("page2", "# second page")
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get("/taipy-init")
         response = client.get("/taipy-init")

+ 5 - 2
tests/gui/gui_specific/test_run_thread.py

@@ -11,6 +11,7 @@
 
 
 import inspect
 import inspect
 import time
 import time
+from unittest.mock import patch
 from urllib.request import urlopen
 from urllib.request import urlopen
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
@@ -20,14 +21,16 @@ from taipy.gui import Gui
 def test_run_thread(gui: Gui, helpers):
 def test_run_thread(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
     gui.add_page("page1", "# first page")
     gui.add_page("page1", "# first page")
-    gui.run(run_in_thread=True, run_browser=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_in_thread=True, run_browser=False)
     while not helpers.port_check():
     while not helpers.port_check():
         time.sleep(0.1)
         time.sleep(0.1)
     assert ">first page</h1>" in urlopen("http://127.0.0.1:5000/taipy-jsx/page1").read().decode("utf-8")
     assert ">first page</h1>" in urlopen("http://127.0.0.1:5000/taipy-jsx/page1").read().decode("utf-8")
     gui.stop()
     gui.stop()
     while helpers.port_check():
     while helpers.port_check():
         time.sleep(0.1)
         time.sleep(0.1)
-    gui.run(run_in_thread=True, run_browser=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_in_thread=True, run_browser=False)
     while not helpers.port_check():
     while not helpers.port_check():
         time.sleep(0.1)
         time.sleep(0.1)
     assert ">first page</h1>" in urlopen("http://127.0.0.1:5000/taipy-jsx/page1").read().decode("utf-8")
     assert ">first page</h1>" in urlopen("http://127.0.0.1:5000/taipy-jsx/page1").read().decode("utf-8")

+ 3 - 1
tests/gui/gui_specific/test_state.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -22,7 +23,8 @@ def test_state(gui: Gui):
     a = 10  # noqa: F841
     a = 10  # noqa: F841
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
     gui.add_page("page1", md_page1)
     gui.add_page("page1", md_page1)
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     state = gui._Gui__state
     state = gui._Gui__state
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         assert state.a == 10
         assert state.a == 10

+ 8 - 3
tests/gui/gui_specific/test_variable_binding.py

@@ -9,6 +9,8 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
+from unittest.mock import patch
+
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 
 
 
 
@@ -25,7 +27,8 @@ def test_variable_binding(helpers):
     z = "button label"
     z = "button label"
     gui = Gui()
     gui = Gui()
     gui.add_page("test", Markdown("<|{x}|> | <|{y}|> | <|{z}|button|on_action=another_function|>"))
     gui.add_page("test", Markdown("<|{x}|> | <|{y}|> | <|{z}|button|on_action=another_function|>"))
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     client = gui._server.test_client()
     client = gui._server.test_client()
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     for expected in ["<Button", 'defaultLabel="button label"', "label={tpec_TpExPr_z_TPMDL_0}"]:
     for expected in ["<Button", 'defaultLabel="button label"', "label={tpec_TpExPr_z_TPMDL_0}"]:
@@ -43,7 +46,8 @@ def test_properties_binding(helpers):
     modifier = "nice "  # noqa: F841
     modifier = "nice "  # noqa: F841
     button_properties = {"label": "A {modifier}button"}  # noqa: F841
     button_properties = {"label": "A {modifier}button"}  # noqa: F841
     gui.add_page("test", Markdown("<|button|properties=button_properties|>"))
     gui.add_page("test", Markdown("<|button|properties=button_properties|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     client = gui._server.test_client()
     client = gui._server.test_client()
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     for expected in ["<Button", 'defaultLabel="A nice button"']:
     for expected in ["<Button", 'defaultLabel="A nice button"']:
@@ -57,7 +61,8 @@ def test_dict_binding(helpers):
     """
     """
     d = {"k": "test"}  # noqa: F841
     d = {"k": "test"}  # noqa: F841
     gui = Gui("<|{d.k}|>")
     gui = Gui("<|{d.k}|>")
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     client = gui._server.test_client()
     client = gui._server.test_client()
     jsx = client.get("/taipy-jsx/TaiPy_root_page").json["jsx"]
     jsx = client.get("/taipy-jsx/TaiPy_root_page").json["jsx"]
     for expected in ["<Field", 'defaultValue="test"']:
     for expected in ["<Field", 'defaultValue="test"']:

+ 7 - 5
tests/gui/helpers.py

@@ -9,14 +9,13 @@
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
-import inspect
 import json
 import json
 import logging
 import logging
 import socket
 import socket
 import time
 import time
 import typing as t
 import typing as t
 import warnings
 import warnings
-from types import FrameType
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Html, Markdown
 from taipy.gui import Gui, Html, Markdown
 from taipy.gui._renderers.builder import _Builder
 from taipy.gui._renderers.builder import _Builder
@@ -49,7 +48,8 @@ class Helpers:
 
 
     @staticmethod
     @staticmethod
     def _test_control(gui: Gui, expected_values: t.Union[str, t.List]):
     def _test_control(gui: Gui, expected_values: t.Union[str, t.List]):
-        gui.run(run_server=False, single_client=True, stylekit=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False, single_client=True, stylekit=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get("/taipy-jsx/test")
         response = client.get("/taipy-jsx/test")
         assert response.status_code == 200, f"response.status_code {response.status_code} != 200"
         assert response.status_code == 200, f"response.status_code {response.status_code} != 200"
@@ -138,14 +138,16 @@ class Helpers:
         kwargs["run_browser"] = False
         kwargs["run_browser"] = False
         kwargs["stylekit"] = kwargs.get("stylekit", False)
         kwargs["stylekit"] = kwargs.get("stylekit", False)
         with warnings.catch_warnings(record=True):
         with warnings.catch_warnings(record=True):
-            gui.run(**kwargs)
+            with patch("sys.argv", ["prog"]):
+                gui.run(**kwargs)
         while not Helpers.port_check():
         while not Helpers.port_check():
             time.sleep(0.1)
             time.sleep(0.1)
 
 
     @staticmethod
     @staticmethod
     def run_e2e_multi_client(gui: Gui):
     def run_e2e_multi_client(gui: Gui):
         with warnings.catch_warnings(record=True):
         with warnings.catch_warnings(record=True):
-            gui.run(run_server=False, run_browser=False, single_client=False, stylekit=False)
+            with patch("sys.argv", ["prog"]):
+                gui.run(run_server=False, run_browser=False, single_client=False, stylekit=False)
             gui._server.run(
             gui._server.run(
                 host=gui._get_config("host", "127.0.0.1"),
                 host=gui._get_config("host", "127.0.0.1"),
                 port=gui._get_config("port", 5000),
                 port=gui._get_config("port", 5000),

+ 3 - 3
tests/gui/ignore/no_file/test_ignore.py

@@ -11,8 +11,7 @@
 
 
 import inspect
 import inspect
 import warnings
 import warnings
-
-import pytest
+from unittest.mock import patch
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
@@ -20,7 +19,8 @@ from taipy.gui import Gui
 def test_no_ignore_file(gui: Gui):
 def test_no_ignore_file(gui: Gui):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get("/resource.txt")
         response = client.get("/resource.txt")
         assert (
         assert (

+ 5 - 4
tests/gui/ignore/with_file/test_with_ignore.py

@@ -11,8 +11,7 @@
 
 
 import inspect
 import inspect
 import warnings
 import warnings
-
-import pytest
+from unittest.mock import patch
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
@@ -20,7 +19,8 @@ from taipy.gui import Gui
 def test_ignore_file_found(gui: Gui):
 def test_ignore_file_found(gui: Gui):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get("/resource.txt")
         response = client.get("/resource.txt")
         assert (
         assert (
@@ -31,7 +31,8 @@ def test_ignore_file_found(gui: Gui):
 def test_ignore_file_not_found(gui: Gui):
 def test_ignore_file_not_found(gui: Gui):
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         gui._set_frame(inspect.currentframe())
         gui._set_frame(inspect.currentframe())
-        gui.run(run_server=False)
+        with patch("sys.argv", ["prog"]):
+            gui.run(run_server=False)
         client = gui._server.test_client()
         client = gui._server.test_client()
         response = client.get("/resource2.txt")
         response = client.get("/resource2.txt")
         assert (
         assert (

+ 3 - 3
tests/gui/long_runnig/test_long_running.py

@@ -11,8 +11,7 @@
 
 
 import inspect
 import inspect
 from time import sleep
 from time import sleep
-
-import pytest
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, State, invoke_long_callback
 from taipy.gui import Gui, State, invoke_long_callback
 
 
@@ -34,7 +33,8 @@ def test_long_callback(gui: Gui):
         state.status = -1
         state.status = -1
 
 
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     state = gui._Gui__state
     state = gui._Gui__state
 
 
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():

+ 3 - 1
tests/gui/renderers/test_html_parsing.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Html
 from taipy.gui import Gui, Html
 
 
@@ -19,7 +20,8 @@ def test_simple_html(gui: Gui, helpers):
     html_string = "<html><head></head><body><h1>test</h1></body></html>"
     html_string = "<html><head></head><body><h1>test</h1></body></html>"
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
     gui.add_page("test", Html(html_string))
     gui.add_page("test", Html(html_string))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     client = gui._server.test_client()
     client = gui._server.test_client()
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     jsx = client.get("/taipy-jsx/test").json["jsx"]
     assert jsx == "<h1>test</h1>"
     assert jsx == "<h1>test</h1>"

+ 5 - 2
tests/gui/server/http/test_extension.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -26,7 +27,8 @@ class MyLibrary(ElementLibrary):
 
 
 
 
 def test_extension_no_config(gui: Gui, helpers):
 def test_extension_no_config(gui: Gui, helpers):
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     with pytest.warns(UserWarning):
     with pytest.warns(UserWarning):
         ret = flask_client.get("/taipy-extension/toto/titi")
         ret = flask_client.get("/taipy-extension/toto/titi")
@@ -35,7 +37,8 @@ def test_extension_no_config(gui: Gui, helpers):
 
 
 def test_extension_config_wrong_path(gui: Gui, helpers):
 def test_extension_config_wrong_path(gui: Gui, helpers):
     Gui.add_library(MyLibrary())
     Gui.add_library(MyLibrary())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     with pytest.warns(UserWarning):
     with pytest.warns(UserWarning):
         ret = flask_client.get("/taipy-extension/taipy_extension_example/titi")
         ret = flask_client.get("/taipy-extension/taipy_extension_example/titi")

+ 13 - 6
tests/gui/server/http/test_file_upload.py

@@ -13,6 +13,7 @@ import inspect
 import io
 import io
 import pathlib
 import pathlib
 import tempfile
 import tempfile
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -22,7 +23,8 @@ from taipy.gui.utils import _get_non_existent_file_path
 
 
 
 
 def test_file_upload_no_varname(gui: Gui, helpers):
 def test_file_upload_no_varname(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)
@@ -32,7 +34,8 @@ def test_file_upload_no_varname(gui: Gui, helpers):
 
 
 
 
 def test_file_upload_no_blob(gui: Gui, helpers):
 def test_file_upload_no_blob(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)
@@ -42,7 +45,8 @@ def test_file_upload_no_blob(gui: Gui, helpers):
 
 
 
 
 def test_file_upload_no_filename(gui: Gui, helpers):
 def test_file_upload_no_filename(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     file = (io.BytesIO(b"abcdef"), "")
     file = (io.BytesIO(b"abcdef"), "")
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
@@ -53,7 +57,8 @@ def test_file_upload_no_filename(gui: Gui, helpers):
 
 
 
 
 def test_file_upload_simple(gui: Gui, helpers):
 def test_file_upload_simple(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)
@@ -72,7 +77,8 @@ def test_file_upload_simple(gui: Gui, helpers):
 
 
 
 
 def test_file_upload_multi_part(gui: Gui, helpers):
 def test_file_upload_multi_part(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)
@@ -104,7 +110,8 @@ def test_file_upload_multi_part(gui: Gui, helpers):
 def test_file_upload_multiple(gui: Gui, helpers):
 def test_file_upload_multiple(gui: Gui, helpers):
     var_name = "varname"
     var_name = "varname"
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         gui._bind_var_val(var_name, None)
         gui._bind_var_val(var_name, None)

+ 5 - 4
tests/gui/server/http/test_image_path.py

@@ -10,14 +10,14 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import pathlib
 import pathlib
-
-import pytest
+from unittest.mock import patch
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
 
 
 def test_image_path_not_found(gui: Gui, helpers):
 def test_image_path_not_found(gui: Gui, helpers):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)
@@ -29,7 +29,8 @@ def test_image_path_found(gui: Gui, helpers):
     url = gui._get_content(
     url = gui._get_content(
         "img", str((pathlib.Path(__file__).parent.parent.parent / "resources" / "fred.png").resolve()), True
         "img", str((pathlib.Path(__file__).parent.parent.parent / "resources" / "fred.png").resolve()), True
     )
     )
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     sid = helpers.create_scope_and_get_sid(gui)
     sid = helpers.create_scope_and_get_sid(gui)

+ 7 - 4
tests/gui/server/http/test_status.py

@@ -10,15 +10,16 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
-import pytest
 from flask import g
 from flask import g
 
 
 from taipy.gui import Gui
 from taipy.gui import Gui
 
 
 
 
 def test_get_status(gui: Gui):
 def test_get_status(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     ret = flask_client.get("/taipy.status.json")
     ret = flask_client.get("/taipy.status.json")
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"
@@ -32,7 +33,8 @@ def test_get_status(gui: Gui):
 
 
 
 
 def test_get_extended_status(gui: Gui):
 def test_get_extended_status(gui: Gui):
-    gui.run(run_server=False, extended_status=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, extended_status=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     ret = flask_client.get("/taipy.status.json")
     ret = flask_client.get("/taipy.status.json")
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"
@@ -56,7 +58,8 @@ def test_get_status_with_user_status(gui: Gui):
 
 
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     ret = flask_client.get("/taipy.status.json")
     ret = flask_client.get("/taipy.status.json")
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"
     assert ret.status_code == 200, f"status_code => {ret.status_code} != 200"

+ 7 - 3
tests/gui/server/http/test_user_content.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -17,7 +18,8 @@ from taipy.gui import Gui
 
 
 
 
 def test_user_content_without_callback(gui: Gui, helpers):
 def test_user_content_without_callback(gui: Gui, helpers):
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     with pytest.warns(UserWarning):
     with pytest.warns(UserWarning):
         ret = flask_client.get(gui._get_user_content_url("path"))
         ret = flask_client.get(gui._get_user_content_url("path"))
@@ -30,7 +32,8 @@ def test_user_content_with_wrong_callback(gui: Gui, helpers):
 
 
     on_user_content = on_user_content_cb
     on_user_content = on_user_content_cb
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     with pytest.warns(UserWarning):
     with pytest.warns(UserWarning):
         ret = flask_client.get(gui._get_user_content_url("path", {"a": "b"}))
         ret = flask_client.get(gui._get_user_content_url("path", {"a": "b"}))
@@ -43,7 +46,8 @@ def test_user_content_with_callback(gui: Gui, helpers):
 
 
     on_user_content = on_user_content_cb
     on_user_content = on_user_content_cb
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     ret = flask_client.get(gui._get_user_content_url("path"))
     ret = flask_client.get(gui._get_user_content_url("path"))
     assert ret.status_code == 200
     assert ret.status_code == 200

+ 3 - 1
tests/gui/server/ws/test_a.py

@@ -11,6 +11,7 @@
 
 
 import inspect
 import inspect
 import time
 import time
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 
 
@@ -28,7 +29,8 @@ def test_a_button_pressed(gui: Gui, helpers):
     gui.add_page(
     gui.add_page(
         "test", Markdown("<|Do something!|button|on_action=do_something|id=my_button|> | <|{x}|> | <|{text}|>")
         "test", Markdown("<|Do something!|button|on_action=do_something|id=my_button|> | <|{x}|> | <|{text}|>")
     )
     )
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/server/ws/test_broadcast.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -28,7 +29,8 @@ def test_broadcast(gui: Gui, helpers):
         "test",
         "test",
         Markdown("<|{selected_val}|selector|multiple|>"),
         Markdown("<|{selected_val}|selector|multiple|>"),
     )
     )
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/server/ws/test_df.py

@@ -12,6 +12,7 @@
 import inspect
 import inspect
 import logging
 import logging
 import pathlib
 import pathlib
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -29,7 +30,8 @@ def test_download_file(gui: Gui, helpers):
     # set gui frame
     # set gui frame
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     # Get the jsx once so that the page will be evaluated -> variable will be registered
     # Get the jsx once so that the page will be evaluated -> variable will be registered

+ 3 - 1
tests/gui/server/ws/test_du.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 
 
@@ -29,7 +30,8 @@ def test_du_table_data_fetched(gui: Gui, helpers, csvdata):
             "<|{csvdata}|table|page_size=10|page_size_options=10;30;100|columns=Day;Entity;Code;Daily hospital occupancy|date_format=eee dd MMM yyyy|>"
             "<|{csvdata}|table|page_size=10|page_size_options=10;30;100|columns=Day;Entity;Code;Daily hospital occupancy|date_format=eee dd MMM yyyy|>"
         ),
         ),
     )
     )
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 5 - 2
tests/gui/server/ws/test_on_change.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -28,7 +29,8 @@ def test_default_on_change(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|{x}|input|>"))
     gui.add_page("test", Markdown("<|{x}|input|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
@@ -56,7 +58,8 @@ def test_specific_on_change(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|{x}|input|on_change=on_input_change|>"))
     gui.add_page("test", Markdown("<|{x}|input|on_change=on_input_change|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/server/ws/test_ru.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -28,7 +29,8 @@ def test_ru_selector(gui: Gui, helpers, csvdata):
         "test",
         "test",
         Markdown("<|{selected_val}|selector|multiple|>"),
         Markdown("<|{selected_val}|selector|multiple|>"),
     )
     )
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/server/ws/test_u.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 
 
@@ -23,7 +24,8 @@ def ws_u_assert_template(gui: Gui, helpers, value_before_update, value_after_upd
 
 
     # Bind a page so that the variable will be evaluated as expression
     # Bind a page so that the variable will be evaluated as expression
     gui.add_page("test", Markdown("<|{var}|>"))
     gui.add_page("test", Markdown("<|{var}|>"))
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 3 - 1
tests/gui/server/ws/test_with.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 from taipy.gui import Gui, Markdown
 from taipy.gui import Gui, Markdown
 from taipy.gui.data.data_scope import _DataScopes
 from taipy.gui.data.data_scope import _DataScopes
@@ -23,7 +24,8 @@ def test_sending_messages_in_group(gui: Gui, helpers):
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
     gui.add_page("test", Markdown("<|Hello {name}|button|id={btn_id}|>"))
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     flask_client = gui._server.test_client()
     flask_client = gui._server.test_client()
     # WS client and emit
     # WS client and emit
     ws_client = gui._server._ws.test_client(gui._server.get_flask())
     ws_client = gui._server._ws.test_client(gui._server.get_flask())

+ 13 - 6
tests/gui/utils/test_evaluator.py

@@ -11,6 +11,7 @@
 
 
 import inspect
 import inspect
 import warnings
 import warnings
+from unittest.mock import patch
 
 
 from flask import g
 from flask import g
 
 
@@ -19,7 +20,8 @@ from taipy.gui.utils.types import _TaipyNumber
 
 
 
 
 def test_unbind_variable_in_expression(gui: Gui, helpers):
 def test_unbind_variable_in_expression(gui: Gui, helpers):
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     with warnings.catch_warnings(record=True) as records:
     with warnings.catch_warnings(record=True) as records:
         with gui.get_flask_app().app_context():
         with gui.get_flask_app().app_context():
             gui._evaluate_expr("{x}")
             gui._evaluate_expr("{x}")
@@ -34,7 +36,8 @@ def test_unbind_variable_in_expression(gui: Gui, helpers):
 def test_evaluate_same_expression_multiple_times(gui: Gui):
 def test_evaluate_same_expression_multiple_times(gui: Gui):
     x = 10  # noqa: F841
     x = 10  # noqa: F841
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         s1 = gui._evaluate_expr("x + 10 = {x + 10}")
         s1 = gui._evaluate_expr("x + 10 = {x + 10}")
         s2 = gui._evaluate_expr("x + 10 = {x + 10}")
         s2 = gui._evaluate_expr("x + 10 = {x + 10}")
@@ -44,7 +47,8 @@ def test_evaluate_same_expression_multiple_times(gui: Gui):
 def test_evaluate_expressions_same_variable(gui: Gui):
 def test_evaluate_expressions_same_variable(gui: Gui):
     x = 10  # noqa: F841
     x = 10  # noqa: F841
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         s1 = gui._evaluate_expr("x + 10 = {x + 10}")
         s1 = gui._evaluate_expr("x + 10 = {x + 10}")
         s2 = gui._evaluate_expr("x = {x}")
         s2 = gui._evaluate_expr("x = {x}")
@@ -54,7 +58,8 @@ def test_evaluate_expressions_same_variable(gui: Gui):
 def test_evaluate_holder(gui: Gui):
 def test_evaluate_holder(gui: Gui):
     x = 10  # noqa: F841
     x = 10  # noqa: F841
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     with warnings.catch_warnings(record=True):
     with warnings.catch_warnings(record=True):
         with gui.get_flask_app().app_context():
         with gui.get_flask_app().app_context():
             gui._evaluate_expr("{x + 10}")
             gui._evaluate_expr("{x + 10}")
@@ -69,7 +74,8 @@ def test_evaluate_holder(gui: Gui):
 
 
 
 
 def test_evaluate_not_expression_type(gui: Gui):
 def test_evaluate_not_expression_type(gui: Gui):
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         assert "x + 10" == gui._evaluate_expr("x + 10")
         assert "x + 10" == gui._evaluate_expr("x + 10")
 
 
@@ -78,7 +84,8 @@ def test_evaluate_expression_2_clients(gui: Gui):
     x = 10  # noqa: F841
     x = 10  # noqa: F841
     y = 20  # noqa: F841
     y = 20  # noqa: F841
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
-    gui.run(run_server=False)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         gui._bindings()._get_or_create_scope("A")
         gui._bindings()._get_or_create_scope("A")
         gui._bindings()._get_or_create_scope("B")
         gui._bindings()._get_or_create_scope("B")

+ 3 - 1
tests/gui/utils/test_map_dict.py

@@ -10,6 +10,7 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 import inspect
 import inspect
+from unittest.mock import patch
 
 
 import pytest
 import pytest
 
 
@@ -118,7 +119,8 @@ def test_map_dict_set(gui: Gui, test_client):
     # set gui frame
     # set gui frame
     gui._set_frame(inspect.currentframe())
     gui._set_frame(inspect.currentframe())
 
 
-    gui.run(run_server=False, single_client=True)
+    with patch("sys.argv", ["prog"]):
+        gui.run(run_server=False, single_client=True)
     with gui.get_flask_app().app_context():
     with gui.get_flask_app().app_context():
         assert isinstance(gui._Gui__state.d, _MapDict)
         assert isinstance(gui._Gui__state.d, _MapDict)
         gui._Gui__state.d = {"b": 2}
         gui._Gui__state.d = {"b": 2}