diff --git a/django_expanded_test_cases/mixins/__init__.py b/django_expanded_test_cases/mixins/__init__.py index 4679864948b566e1eddd0b7da5eab02ebe1c7469..d5eddac309694c6979c54dbc6dda36f71a23ab9b 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 39060c1aab6bc11db6b3180625ab1d46e97d1bd0..d631c0c9e9940187f7c745eecb038a5bba8910a6 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/