Skip to content

Commit 251ec82

Browse files
committed
🙈 disable fancy-pants browser tests on non-linux platforms
1 parent fe43106 commit 251ec82

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

tests/fr_selenium.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
__author__ = "Jonas Van Der Donckt, Jeroen Van Der Donckt"
1313

14-
import sys
1514
import json
1615
import time
1716
from typing import List, Union
@@ -20,21 +19,15 @@
2019
from seleniumwire.request import Request
2120
from selenium.webdriver.common.action_chains import ActionChains
2221
from selenium.webdriver.common.by import By
23-
from selenium.webdriver.firefox.options import Options
2422
from selenium.webdriver.support import expected_conditions as EC
2523
from selenium.webdriver.support.ui import WebDriverWait
2624

27-
28-
def not_on_linux():
29-
"""Return True if the current platform is not Linux.
30-
31-
Note: this will be used to add more waiting time to windows & mac os tests as
32-
- on these OS's serialization of the figure is necessary (to start the dash app in a
33-
multiprocessing.Process)
34-
https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
35-
- on linux, the browser (i.e., sending & getting requests) goes a lot faster
36-
"""
37-
return not sys.platform.startswith("linux")
25+
# Note: this will be used to add more waiting time to windows & mac os tests as
26+
# - on these OS's serialization of the figure is necessary (to start the dash app in a
27+
# multiprocessing.Process)
28+
# https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
29+
# - on linux, the browser (i.e., sending & getting requests) goes a lot faster
30+
from .utils import not_on_linux
3831

3932

4033
# https://www.blazemeter.com/blog/improve-your-selenium-webdriver-tests-with-pytest

tests/test_figure_resampler.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from plotly.subplots import make_subplots
1818
from plotly_resampler import FigureResampler, LTTB, EveryNthPoint
1919

20+
# Note: this will be used to skip / alter behavior when running browser tests on
21+
# non-linux platforms.
22+
from .utils import not_on_linux
23+
2024

2125
def test_add_trace_kwarg_space(float_series, bool_series, cat_series):
2226
# see: https://plotly.com/python/subplots/#custom-sized-subplot-with-subplot-titles
@@ -1087,13 +1091,17 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints-1):
10871091
# Even after updating the axes ranges
10881092
check_data(f_pr)
10891093

1094+
if not_on_linux():
1095+
# TODO: eventually we should run this test on Windows & MacOS too
1096+
return
1097+
10901098
f_pr.stop_server()
10911099
proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
10921100
proc.start()
10931101
try:
1094-
time.sleep(2)
1102+
time.sleep(1)
10951103
driver.get(f"http://localhost:8050")
1096-
time.sleep(7)
1104+
time.sleep(3)
10971105
# Get the data property from the front-end figure
10981106
el = driver.find_element(by=By.ID, value="resample-figure")
10991107
el = el.find_element(by=By.CLASS_NAME, value="js-plotly-plot")
@@ -1171,13 +1179,17 @@ def check_data(fr: FigureResampler, min_v=0, max_v=nb_datapoints-1):
11711179
# Even after updating the axes ranges
11721180
check_data(f_pr)
11731181

1182+
if not_on_linux():
1183+
# TODO: eventually we should run this test on Windows & MacOS too
1184+
return
1185+
11741186
f_pr.stop_server()
11751187
proc = multiprocessing.Process(target=f_pr.show_dash, kwargs=dict(mode="external"))
11761188
proc.start()
11771189
try:
1178-
time.sleep(2)
1190+
time.sleep(1)
11791191
driver.get(f"http://localhost:8050")
1180-
time.sleep(7)
1192+
time.sleep(3)
11811193
# Get the data & layout property from the front-end figure
11821194
el = driver.find_element(by=By.ID, value="resample-figure")
11831195
el = el.find_element(by=By.CLASS_NAME, value="js-plotly-plot")

tests/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import sys
2+
3+
def not_on_linux():
4+
"""Return True if the current platform is not Linux.
5+
6+
This is to avoid / alter test bahavior for non-Linux (as browser testing gets
7+
tricky on other platforms).
8+
"""
9+
return not sys.platform.startswith("linux")

0 commit comments

Comments
 (0)