Skip to content

Commit 7774af1

Browse files
committed
Adds port env var tests
1 parent da3f4ff commit 7774af1

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

dash/_configs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def load_dash_env_vars():
2929
'DASH_HOT_RELOAD_MAX_RETRY',
3030
'DASH_SILENCE_ROUTES_LOGGING',
3131
'DASH_PRUNE_ERRORS',
32-
'DASH_COMPRESS'
32+
'DASH_COMPRESS',
33+
'HOST',
34+
'PORT'
3335
)
3436
}
3537
)

tests/integration/test_integration.py

+7
Original file line numberDiff line numberDiff line change
@@ -1019,3 +1019,10 @@ def g2(a):
10191019
@app.callback(Output("inner-div", "children"), [Input("inner-input", "value")])
10201020
def h(a):
10211021
return a
1022+
1023+
def test_inin_024_port_env_success(dash_duo):
1024+
app = Dash(__name__)
1025+
app.layout = html.Div("hi", "out")
1026+
dash_duo.start_server(app, port="12345")
1027+
assert dash_duo.server_url == "http://localhost:12345"
1028+
dash_duo.wait_for_text_to_equal("#out", "hi")

tests/unit/test_configs.py

+17
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,20 @@ def test_strip_relative_path(prefix, partial_path, expected):
238238
def test_invalid_strip_relative_path(prefix, partial_path):
239239
with pytest.raises(_exc.UnsupportedRelativePath):
240240
strip_relative_path(prefix, partial_path)
241+
242+
243+
def test_port_env_fail_str(empty_environ):
244+
app = Dash()
245+
with pytest.raises(Exception) as excinfo:
246+
app.run_server(port="garbage")
247+
assert(excinfo.exconly() == "ValueError: Expecting an integer from 1 to 65535, found port='garbage'")
248+
249+
def test_port_env_fail_range(empty_environ):
250+
app=Dash()
251+
with pytest.raises(Exception) as excinfo:
252+
app.run_server(port="0")
253+
assert(excinfo.exconly() == "AssertionError: Expecting an integer from 1 to 65535, found port=0")
254+
255+
with pytest.raises(Exception) as excinfo:
256+
app.run_server(port="65536")
257+
assert(excinfo.exconly() == "AssertionError: Expecting an integer from 1 to 65535, found port=65536")

0 commit comments

Comments
 (0)