|
8 | 8 | import pytest
|
9 | 9 | import requests
|
10 | 10 | from imageio.v3 import imread
|
| 11 | +from packaging.version import Version |
11 | 12 | from selenium.webdriver.common.by import By
|
12 | 13 | from selenium.webdriver.common.keys import Keys
|
13 | 14 | from selenium.webdriver.remote.webelement import WebElement
|
@@ -41,45 +42,6 @@ def crop_const_color_borders(image: np.ndarray, const_color: int = 255):
|
41 | 42 | return image[i1:i2, j1:j2, :]
|
42 | 43 |
|
43 | 44 |
|
44 |
| -if JUPYTER_TYPE == "notebook": |
45 |
| - BUTTON_CLASS_NAME = "lm-Widget.jupyter-widgets.jupyter-button.widget-button" |
46 |
| - OUTPUT_CLASS_NAME = "lm-Widget.jp-RenderedText.jp-mod-trusted.jp-OutputArea-output" |
47 |
| - TEXT_INPUT_CLASS_NAME = "widget-input" |
48 |
| - CODE_MIRROR_CLASS_NAME = "CodeMirror-code" |
49 |
| - MATPLOTLIB_CANVAS_CLASS_NAME = "jupyter-widgets.jupyter-matplotlib-canvas-container" |
50 |
| - CUE_BOX_CLASS_NAME = ( |
51 |
| - "lm-Widget.lm-Panel.jupyter-widgets.widget-container" |
52 |
| - ".widget-box.widget-vbox.scwidget-cue-box" |
53 |
| - ) |
54 |
| -elif JUPYTER_TYPE == "lab": |
55 |
| - BUTTON_CLASS_NAME = ( |
56 |
| - "lm-Widget.p-Widget.jupyter-widgets.jupyter-button.widget-button" |
57 |
| - ) |
58 |
| - OUTPUT_CLASS_NAME = ( |
59 |
| - "lm-Widget.p-Widget.jp-RenderedText.jp-mod-trusted.jp-OutputArea-output" |
60 |
| - ) |
61 |
| - TEXT_INPUT_CLASS_NAME = "widget-input" |
62 |
| - CODE_MIRROR_CLASS_NAME = "CodeMirror-code" |
63 |
| - |
64 |
| - MATPLOTLIB_CANVAS_CLASS_NAME = "jupyter-widgets.jupyter-matplotlib-canvas-container" |
65 |
| - CUE_BOX_CLASS_NAME = ( |
66 |
| - "lm-Widget.p-Widget.lm-Panel.p-Panel.jupyter-widgets." |
67 |
| - "widget-container.widget-box.widget-vbox.scwidget-cue-box" |
68 |
| - ) |
69 |
| -else: |
70 |
| - raise ValueError( |
71 |
| - f"Tests do not support jupyter type {JUPYTER_TYPE!r}. Please use 'notebook' or" |
72 |
| - " 'lab'." |
73 |
| - ) |
74 |
| - |
75 |
| -CUED_CUE_BOX_CLASS_NAME = f"{CUE_BOX_CLASS_NAME}.scwidget-cue-box--cue" |
76 |
| - |
77 |
| -RESET_CUE_BUTTON_CLASS_NAME = f"{BUTTON_CLASS_NAME}.scwidget-reset-cue-button" |
78 |
| -CUED_RESET_CUE_BUTTON_CLASS_NAME = ( |
79 |
| - f"{RESET_CUE_BUTTON_CLASS_NAME}.scwidget-reset-cue-button--cue" |
80 |
| -) |
81 |
| - |
82 |
| - |
83 | 45 | def cue_box_class_name(cue_type: str, cued: bool):
|
84 | 46 | class_name = CUED_CUE_BOX_CLASS_NAME if cued else CUE_BOX_CLASS_NAME
|
85 | 47 | if cue_type is None:
|
@@ -156,6 +118,62 @@ def test_notebook_running(notebook_service):
|
156 | 118 | assert response.status_code == 200
|
157 | 119 |
|
158 | 120 |
|
| 121 | +def test_setup_globals(): |
| 122 | + from .conftest import JUPYTER_VERSION |
| 123 | + |
| 124 | + # black formats this into one line which causes an error in the linter. |
| 125 | + # fmt: off |
| 126 | + global BUTTON_CLASS_NAME, OUTPUT_CLASS_NAME, TEXT_INPUT_CLASS_NAME, \ |
| 127 | + CODE_MIRROR_CLASS_NAME, MATPLOTLIB_CANVAS_CLASS_NAME, CUE_BOX_CLASS_NAME |
| 128 | + global CUED_CUE_BOX_CLASS_NAME, RESET_CUE_BUTTON_CLASS_NAME, \ |
| 129 | + CUED_RESET_CUE_BUTTON_CLASS_NAME |
| 130 | + # fmt: on |
| 131 | + |
| 132 | + if JUPYTER_TYPE == "notebook" and JUPYTER_VERSION >= Version("7.0.0"): |
| 133 | + BUTTON_CLASS_NAME = "lm-Widget.jupyter-widgets.jupyter-button.widget-button" |
| 134 | + OUTPUT_CLASS_NAME = ( |
| 135 | + "lm-Widget.jp-RenderedText.jp-mod-trusted.jp-OutputArea-output" |
| 136 | + ) |
| 137 | + TEXT_INPUT_CLASS_NAME = "widget-input" |
| 138 | + CODE_MIRROR_CLASS_NAME = "cm-content" |
| 139 | + MATPLOTLIB_CANVAS_CLASS_NAME = ( |
| 140 | + "jupyter-widgets.jupyter-matplotlib-canvas-container" |
| 141 | + ) |
| 142 | + CUE_BOX_CLASS_NAME = ( |
| 143 | + "lm-Widget.lm-Panel.jupyter-widgets.widget-container" |
| 144 | + ".widget-box.widget-vbox.scwidget-cue-box" |
| 145 | + ) |
| 146 | + elif JUPYTER_TYPE == "lab" and JUPYTER_VERSION < Version("4.0.0"): |
| 147 | + BUTTON_CLASS_NAME = ( |
| 148 | + "lm-Widget.p-Widget.jupyter-widgets.jupyter-button.widget-button" |
| 149 | + ) |
| 150 | + OUTPUT_CLASS_NAME = ( |
| 151 | + "lm-Widget.p-Widget.jp-RenderedText.jp-mod-trusted.jp-OutputArea-output" |
| 152 | + ) |
| 153 | + TEXT_INPUT_CLASS_NAME = "widget-input" |
| 154 | + CODE_MIRROR_CLASS_NAME = "cm-content" |
| 155 | + |
| 156 | + MATPLOTLIB_CANVAS_CLASS_NAME = ( |
| 157 | + "jupyter-widgets.jupyter-matplotlib-canvas-container" |
| 158 | + ) |
| 159 | + CUE_BOX_CLASS_NAME = ( |
| 160 | + "lm-Widget.p-Widget.lm-Panel.p-Panel.jupyter-widgets." |
| 161 | + "widget-container.widget-box.widget-vbox.scwidget-cue-box" |
| 162 | + ) |
| 163 | + else: |
| 164 | + raise ValueError( |
| 165 | + f"Tests do not support jupyter type {JUPYTER_TYPE!r} for version" |
| 166 | + f"{JUPYTER_VERSION!r}." |
| 167 | + ) |
| 168 | + |
| 169 | + CUED_CUE_BOX_CLASS_NAME = f"{CUE_BOX_CLASS_NAME}.scwidget-cue-box--cue" |
| 170 | + |
| 171 | + RESET_CUE_BUTTON_CLASS_NAME = f"{BUTTON_CLASS_NAME}.scwidget-reset-cue-button" |
| 172 | + CUED_RESET_CUE_BUTTON_CLASS_NAME = ( |
| 173 | + f"{RESET_CUE_BUTTON_CLASS_NAME}.scwidget-reset-cue-button--cue" |
| 174 | + ) |
| 175 | + |
| 176 | + |
159 | 177 | def test_privacy_policy(selenium_driver):
|
160 | 178 | """
|
161 | 179 | The first time jupyter lab is started on a fresh installation a privacy popup
|
|
0 commit comments