Explorar el Código

Allow nicegui.test to be used without selenium dependencies (#3585)

* allow nicegui.test to be used without selenium dependencies

* show import error when Screen is accessed without the proper deps

* re-raise original error

* simplified code as discussed in #3510
Rodja Trappe hace 9 meses
padre
commit
3586722bbc
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8 1
      nicegui/testing/__init__.py

+ 8 - 1
nicegui/testing/__init__.py

@@ -1,4 +1,11 @@
-from .screen import Screen
+try:
+    from .screen import Screen
+except ImportError:
+    # we simply define Screen as None if selenium is not installed
+    # this allows simpler dependency management when only using the "User" fixture
+    # (see discussion in #3510)
+    Screen = None  # type: ignore
+
 from .user import User
 from .user_interaction import UserInteraction