Skip to content

Fixed bug that prevented env DASH_DEBUG to work #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ def run(
host=os.getenv("HOST", "127.0.0.1"),
port=os.getenv("PORT", "8050"),
proxy=os.getenv("DASH_PROXY", None),
debug=False,
debug=None,
dev_tools_ui=None,
dev_tools_props_check=None,
dev_tools_serve_dev_bundles=None,
Expand Down Expand Up @@ -1987,6 +1987,9 @@ def run(

:return:
"""
if debug is None:
debug = get_combined_config("debug", None, False)

debug = self.enable_dev_tools(
debug,
dev_tools_ui,
Expand Down
46 changes: 46 additions & 0 deletions tests/unit/test_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,49 @@ def test_app_invalid_delayed_config():
app = Dash(server=False)
with pytest.raises(AttributeError):
app.init_app(app=Flask("test"), name="too late 2 update")


@pytest.mark.parametrize(
"debug_env, debug, expected",
[
(None, None, False),
(None, True, True),
(None, False, False),
('True', None, True),
('True', True, True),
('True', False, False),
('False', None, False),
('False', True, True),
('False', False, False),
],
)
def test_debug_mode_run(empty_environ, debug_env, debug, expected):
if debug_env:
os.environ['DASH_DEBUG'] = debug_env
app = Dash()
with pytest.raises(AssertionError):
app.run(debug=debug, port=-1)
assert app._dev_tools.ui == expected


@pytest.mark.parametrize(
"debug_env, debug, expected",
[
(None, None, True),
(None, True, True),
(None, False, False),
('True', None, True),
('True', True, True),
('True', False, False),
('False', None, False),
('False', True, True),
('False', False, False),
],
)
def test_debug_mode_enable_dev_tools(empty_environ, debug_env, debug, expected):
if debug_env:
os.environ['DASH_DEBUG'] = debug_env
app = Dash()
# with pytest.raises(AssertionError):
app.enable_dev_tools(debug=debug)
assert app._dev_tools.ui == expected