Skip to content

test: add tests for #123 #176

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 3 commits into from
Mar 7, 2023
Merged
Changes from all 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
32 changes: 30 additions & 2 deletions tests/test_figure_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import datetime
import multiprocessing
import subprocess
import time
from typing import List

Expand Down Expand Up @@ -901,6 +902,33 @@ def test_stop_server_inline_persistent():
proc.terminate()


def test_showdash_not_hanging_when_port_in_use():
if not_on_linux():
pytest.skip("This test is currently only supported on linux")

port = 8032

start_fig = "from plotly_resampler import FigureResampler; "
start_fig += (
f"FigureResampler().show_dash(mode='external', port={port}, debug=False)"
)

# Start the first figure in another python interpreter
p1 = subprocess.Popen(["python", "-c", start_fig])
# Wait a little bit
time.sleep(3)

# Start the second figure in the current python interpreter
with pytest.raises(SystemExit):
# Start the second figure
FigureResampler().show_dash(mode="external", port=port)
# Wait a little bit
time.sleep(3)

# Stop the first figure
p1.kill()


def test_manual_jupyterdashpersistentinline():
# Manually call the JupyterDashPersistentInline its method
# This requires some gimmicky stuff to mimmick the behaviour of a jupyter notebook.
Expand Down Expand Up @@ -1336,7 +1364,7 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints - 1):

if not_on_linux():
# TODO: eventually we should run this test on Windows & MacOS too
return
pytest.skip("This test is currently only run on Linux")

f_pr.stop_server()
proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
Expand Down Expand Up @@ -1424,7 +1452,7 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints - 1):

if not_on_linux():
# TODO: eventually we should run this test on Windows & MacOS too
return
pytest.skip("This test is currently only run on Linux")

f_pr.stop_server()
proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
Expand Down