浏览代码

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 9 月之前
父节点
当前提交
3586722bbc
共有 1 个文件被更改,包括 8 次插入1 次删除
  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 import User
 from .user_interaction import UserInteraction
 from .user_interaction import UserInteraction