Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 37e66e6

Browse files
committedMar 4, 2020
Adds port env var tests
1 parent da3f4ff commit 37e66e6

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed
 

Diff for: ‎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
)

Diff for: ‎tests/integration/test_integration.py

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

Diff for: ‎tests/unit/test_configs.py

+27
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,30 @@ 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 (
248+
excinfo.exconly()
249+
== "ValueError: Expecting an integer from 1 to 65535, found port='garbage'"
250+
)
251+
252+
253+
def test_port_env_fail_range(empty_environ):
254+
app = Dash()
255+
with pytest.raises(Exception) as excinfo:
256+
app.run_server(port="0")
257+
assert (
258+
excinfo.exconly()
259+
== "AssertionError: Expecting an integer from 1 to 65535, found port=0"
260+
)
261+
262+
with pytest.raises(Exception) as excinfo:
263+
app.run_server(port="65536")
264+
assert (
265+
excinfo.exconly()
266+
== "AssertionError: Expecting an integer from 1 to 65535, found port=65536"
267+
)

0 commit comments

Comments
 (0)
Please sign in to comment.