From a29574c5808edbadc043b6ea7147c9e4083853d8 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Wed, 22 Nov 2023 00:46:24 -0500
Subject: [PATCH] Correct project handling when selenium package is not
 installed

---
 django_expanded_test_cases/mixins/__init__.py | 28 ++++++++++++++++++-
 .../test_cases/__init__.py                    |  3 +-
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/django_expanded_test_cases/mixins/__init__.py b/django_expanded_test_cases/mixins/__init__.py
index 4679864..d5eddac 100644
--- a/django_expanded_test_cases/mixins/__init__.py
+++ b/django_expanded_test_cases/mixins/__init__.py
@@ -12,4 +12,30 @@ from .response_mixin import ResponseTestCaseMixin
 
 
 # Expanded "LiveServer" TestCase utility mixins.
-from .live_server_mixin import LiveServerMixin
+try:
+    from .live_server_mixin import LiveServerMixin
+except ModuleNotFoundError:
+    # Project likely does not have selenium package installed.
+    # This is okay, as we don't want this logic as a hard requirement to use this library.
+
+    # However, we do want to define a dummy class to give feedback errors.
+    class LiveServerTestCase():
+        err_msg = """
+        Cannot use LiveServer TestCases class without "selenium" package installed.
+        To use these TestCases, add the following packages to your project:
+            * selenium              # Required
+            * channels              # Optional, used in ChannelsLiveServerTestCase only.
+            * daphne                # Optional, used in ChannelsLiveServerTestCase only.
+
+        For more information, see:
+        https://www.selenium.dev/documentation/webdriver/getting_started/
+        """
+        @classmethod
+        def setUpClass(cls):
+            raise Exception(cls.err_msg)
+
+        def setUp(self):
+            raise Exception(self.err_msg)
+
+        def __int__(self):
+            raise Exception(self.err_msg)
diff --git a/django_expanded_test_cases/test_cases/__init__.py b/django_expanded_test_cases/test_cases/__init__.py
index 39060c1..d631c0c 100644
--- a/django_expanded_test_cases/test_cases/__init__.py
+++ b/django_expanded_test_cases/test_cases/__init__.py
@@ -24,7 +24,6 @@ except ModuleNotFoundError:
         Cannot use LiveServerTestCase class without "selenium" package installed.
         To use this TestCase, add the following packages to your project:
             * selenium              # Required
-            * webdriver-manager     # Required
 
         For more information, see:
         https://www.selenium.dev/documentation/webdriver/getting_started/
@@ -54,7 +53,7 @@ except ModuleNotFoundError:
         To use this TestCase, add the following packages to your project:
             * channels              # Required
             * daphne                # Required
-            * webdriver-manager     # Required
+            * selenium              # Required
 
         For more information, see:
         https://www.selenium.dev/documentation/webdriver/getting_started/
-- 
GitLab